PopupWindow与软键盘的相爱相杀
程序员文章站
2022-04-20 09:02:12
...
写popupwindow弹出框的时候软键盘会覆盖popupwindow,需要添加 popview.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED)
popview.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 但是7.0之后添加这两行代码没有用,需要去判断sdk是否是7.0,如果是
private void showPpw(PopupWindow popupWindow) {
if (Build.VERSION.SDK_INT < 24) {
popupWindow.showAsDropDown(view);
} else {
int[] location = new int[2];
view.getLocationOnScreen(location);
popupWindow.showAtLocation(mLine, Gravity.NO_GRAVITY, location[0], location[1] + 2);
}
}
重写后不覆盖了但是pop跑到了顶部,判断如果是7.0
if (Build.VERSION.SDK_INT != 24) {
popupWindow.update();
}