Android PopupWindow 隐藏软键盘的方法
查了好久,最后google到了解决方式,顺便记录一下
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)
imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
这句话解决了我的问题
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
然后想要不让PopupWindow/软键盘弹出时activity自动向上收缩,界面扭曲,在AndroidManifest.xml文件中,将此Activity的软键盘属性设置为
android:windowSoftInputMode="adjustPan"
//防止PopupWindow被软件盘挡住
setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED)
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
setOutsideTouchable(true);
setFocusable(true);