軟鍵盤遮擋PopupWindow 解決方法
1.Activity Android AndroidManifest.xml中添加
android:windowSoftInputMode="stateHidden|adjustResize"
2.PopupWindow 中設(shè)置
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
popupwindow 關(guān)閉軟鍵盤不關(guān)閉解決方法
1.先寫判斷軟鍵盤是否關(guān)閉方法
private boolean isSoftShowing() {
// 獲取當前屏幕內(nèi)容的高度
int screenHeight = getWindow().getDecorView().getHeight();
// 獲取View可見區(qū)域的bottom
Rect rect = new Rect();
// DecorView即為activity的頂級view
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
// 考慮到虛擬導航欄的情況(虛擬導航欄情況下:screenHeight = rect.bottom + 虛擬導航欄高度)
// 選取screenHeight*2/3進行判斷
return screenHeight*2/3 > rect.bottom;
}
2.關(guān)閉軟件盤
InputMethodManager inputMethodManager = (InputMethodManager)
context.getSystemService(Activity.INPUT_METHOD_SERVICE);
if(isSoftShowing()){
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}