Android 自定义WebView点击输入框不弹出软键盘;
16lz
2021-01-23
假如这个是你的自定义WebView:
public class XWebView extends WebView { public XWebView(Context context) { this(context, null); } public XWebView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public XWebView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); initWebViewSettings(context); }}
那么你的WebView弹不出软键盘是正常的;且看第二个构造方法:this(context, attributeSet, 0); 看到这个0了吗?把它改为 com.android.internal.R.attr.webViewStyle ;如果编译报错的话就试试这个Resources.getSystem().getIdentifier("webViewStyle","attr","android")
public class XWebView extends WebView { public XWebView(Context context) { this(context, null); } /** * 不能直接调用this(context, attrs,0),最后style是0的话,会导致无法响应点击动作。 */ public XWebView(Context context, AttributeSet attributeSet) { this(context, attributeSet, Resources.getSystem().getIdentifier("webViewStyle","attr","android")); } public XWebView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); initWebViewSettings(context); }}
this(context, attributeSet, Resources.getSystem().getIdentifier("webViewStyle","attr","android"));
OK
更多相关文章
- 解决ios软键盘输入框被遮挡问题
- Android软键盘遮挡布局的那些事
- Android点击事件隐藏软键盘
- android隐藏弹出软键盘
- android 点击空白 隐藏软键盘
- Android判断软键盘是否显示
- Android点击按钮隐藏或者打开软键盘