我正在使用显示表单的WebView。当我点击输入字段时,android系统会显示一个softKeyboard。
比,我怎么能显示纯文字键盘?因为现在,在键盘上我可以看到表情符号按钮,我想隐藏它。
使用自定义WebView我可以覆盖onCreateInputConnection
但我只能设置类型但不能隐藏表情符号。
我知道这不是一个好的解决方案。但是,在找到最佳解决方案之前,它会很有用。
将以下属性添加到xml
android:digits="qwertyuiopasdfghjklzxcvbnm 1234567890 QWERTYUIOPASDFGHJKLZXCVBNM"
例
<EditText
android:digits="qwertyuiopasdfghjklzxcvbnm 1234567890 QWERTYUIOPASDFGHJKLZXCVBNM"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
您应该创建自定义WebView并覆盖onCreateInputConnection
,如下所示:
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
outAttrs.inputType =InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
return connection;
}