android sdk 升级后 ,不知为何潜逃的原生webview无法弹起键盘
检查下你的WebView是否是自定义过的。如果是的话,构造方法注意一下,如果写法如下图所示则无法弹出
public BaseWebView(Context context) {
this(context, (AttributeSet)null);
}
public BaseWebView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public BaseWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mContext = context;
this.init();
}
应改为:
public BaseWebView(Context context) {
super(context);
this.mContext = context;
init();
}
**public BaseWebView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
init();
}**
public BaseWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mContext = context;
init();
}
**问题原因处在最后的defStyleAttr,不能设置为0,应设置为com.android.internal.R.attr.webViewStyle!具体这个styleable里的参数是什么,暂且还未找到相关代码**。
参考文章:https://blog.csdn.net/Aran_biubiu/article/details/108326075
文章讨论了AndroidSDK升级后,原生WebView的键盘弹出问题,指出自定义构造方法中的defStyleAttr设置为0导致问题,正确方式是设置为webViewStyle。作者提醒检查相关styleable参数。

4327

被折叠的 条评论
为什么被折叠?



