android嵌套H5键盘不弹起

文章讨论了AndroidSDK升级后,原生WebView的键盘弹出问题,指出自定义构造方法中的defStyleAttr设置为0导致问题,正确方式是设置为webViewStyle。作者提醒检查相关styleable参数。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值