Skip to content

PopupWindow中EditText无法编辑,无法弹出软键盘

要解决这个问题,需要对PopupWindow进行设置。设置popupWindow允许获得关注。 新建对象时设置focusable=true,或popupWindow.setFocusable(true)

popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);

popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);