直接上代码了
private PopupWindowpopup;
private Viewroot;
在onCreat()中
root =this.getLayoutInflater().inflate(R.layout.pop_scann, null);
//设置弹出布局自适应大小
popup = new PopupWindow(root, WindowManager.LayoutParams.MATCH_PARENT, 400);
popup.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
popup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
popup.setFocusable(true); //自定义布局里面有editText的时候,加上这个就可以弹出软键盘了
在要开启的地方(点击事件里面)
popup.showAtLocation(view, Gravity.BOTTOM, 0, 0);
自定义布局里面有editText的时候,无法弹出软键盘
popup.setFocusable(true);
弹出软键盘遮住Popupwindow
popupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
网友评论