android - 当 EditText 获得焦点时显示一个风格化的键盘
问题描述
我正在开发一个使用键盘进行输入的游戏,但是当用户触摸输入字段时,我只想显示字母字符,没有数字或特殊符号。现在,当键盘打开时,应用程序如下所示:
当“键入一些字母”EditText 具有焦点时,如何用自定义键盘替换软键盘?
解决方案
I ended up creating a layout of the keyboard I wanted and then I disabled the focus for the EditText:
<EditText
android:id="@+id/typed_word"
android:focusable="false"
android:maxLength="10"
android:inputType="text"
android:textCursorDrawable="@drawable/custom_cursor"
android:enabled="false"
android:layout_below="@+id/word_list"
android:digits="abcdefghijklmnopqrstuvwxyz"
android:textSize="25sp"
android:textColor="@color/colorPrimaryDark"
android:layout_margin="10dp"
android:hint="@string/type_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
By disabling the focus, I was able to prevent the standard keyboard from being displayed.
推荐阅读
- data-structures - 为什么教科书中的splay树与我的不同?
- javascript - 使用 NodeJS + HTML 建立 MySQL 数据库似乎不起作用
- html - 我正在尝试使用 PyMySQL 设计一个基本的 CRUD 应用程序并得到一个“KEY ERROR”
- spring-boot - 将 Spring Boot 微服务部署到 Heroku
- python - 评估 k 折交叉验证中的准确性与保留数据
- python - Python从最高分到最低分读取txt文件
- anaconda - 指定从 yml 文件创建 conda 后要运行的命令
- python-3.x - 在硒中发生变化后如何获取元素?
- c# - C#同时执行多个方法,方法并发
- python - 从一个 sqlite3 表中的列中获取值并插入到另一个表中