奇葩的事情99%都是有原因的,最近碰到了一个webview打开网页不能弹出键盘的问题
百度了好久都说是自定义webview的构造方法默认属性不能传 0 导致的。如下错误写法:
public CommonWebView(Context context) {
this(context,null,0);
}
public CommonWebView(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public CommonWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
检查了自己代码也没有这个问题呢。
根据现象是input标签没有获取到焦点,导致不能弹出键盘。检查了代码也没有特殊的操作,于是在xml中发现了“
android:descendantFocusability="blocksDescendants"“这个属性,父容器抢占子控件焦点。到这里问题才解决了