今天继续做浮框效果,发现当PopupWindow当中包含EditText时,popupWindow出现后,editText自动猎取焦点,但是软键盘却不能跟着出现。
同样的问题:
http://stackoverflow.com/questions/3915230/how-to-show-keyboard-on-popupwindow
http://stackoverflow.com/questions/4593610/android-popupwindow-window-focus-selection/8500786#8500786
原因终于找到了,在我的代码中:
PopupWindow mPopupWindow = new PopupWindow(poupView, 300,300); 我用的是两个参数的构造函数。
查看PopupWindow.java的源代码后发现:
/**
* <p>Create a new non focusable popup window which can display the
* <tt>contentView</tt>. The dimension of the window must be passed to
* this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
*/
public PopupWindow(View contentView, int width, int height) {
this(contentView, width, height, false);
}
/**
* <p>Create a new popup window which can display the <tt>contentView</tt>.
* The dimension of the window must be passed to this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
* @param focusable true if the popup can be focused, false otherwise
*/
public PopupWindow(View contentView, int width, int height, boolean focusable) {
if (contentView != null) {
mContext = contentView.getContext();
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
setContentView(contentView);
setWidth(width);
setHeight(height);
setFocusable(focusable);
}
所以就明白,为什么软键盘会不出现了?
解决方法,换一个构造函数,哈哈。
分享到:
相关推荐
android edittext不弹出软键盘三种方法“: 方法一: 在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden 例如: android:label="@string/app_name" ...
能很完美的解决文本框被软键盘挡住的问题,使你的界面更漂亮,更人性化。。
软键盘顶起popupwindow方法,popupWindow内含输入框
PopupWindow显示EditText输入内容,EditText失去焦点PopupWindow dismiss,EditText获得焦点PopupWindow show 输入时显示
DialogFragment,解决PopupWindow中EditText无法复制粘贴问题。Blog地址:https://blog.csdn.net/qq_37077360/article/details/83505119
这两天android app新增了透明栏效果,结果发现键盘弹起后会遮盖屏幕底部的EditText,没有像想象中的调整窗口大小,并滚动ScrollView,将EditText显示在键盘上方。之前也遇到过类似问题,所以解决后就干脆写把所有...
实现的功能有弹出的PopupWindow上有EditText能与软键盘并存不冲突,弹出PopupWindow的时候背景自动改变灰度为半透明黑色,消失后背景灰度复原,PopupWindow还能根据自己的实际需求制定自己想要的弹出动画,以及...
android edittext spinner popupwindow 实现类似qq,保存用户名的功能 android ,差了一天才得到的结果,我要5分不为过
NULL 博文链接:https://wen742538485.iteye.com/blog/1560745
android 模仿qq登录界面EditText下拉框记住账号和密码 editText+popupwindow+sqlite方式实现
主要介绍了Android中解决EditText放到popupWindow中,原有复制、粘贴、全选、选择功能失效问题 的相关资料,需要的朋友可以参考下
Andorid例子源码popupWindow自定义键盘控件
android 软键盘把界面顶起的问题 ,研究大半天,希望对大家有帮助。
自定随机密码键盘并适配计算界面需要滚的高度防止弹出的popupwindow遮盖点击的输入框
继承edittext 在里面封装一个popupwindow ,代码易懂,简单有效