andorid 獲取鍵盤高度

	private int softBoardHeight;
	private void getSoftBoardHeight() {
		rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
			@Override
			public void onGlobalLayout() {
				if (topStart == 0) {
					topStart = getPanelHeight();// 沒取到一直取
				}
				int cur = getPanelHeight();
				if (topStart > 0 && softBoardHeight < 100 && cur > 0) {
					softBoardHeight = topStart - cur;
				}
			}
		});
	}
private int getPanelHeight() {
    int[] lo = new int[2];
    et_input.getLocationInWindow(lo);
    return lo[1];
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章