用户登录
用户注册

分享至

安卓应用专用软键盘

  • 作者: 抱着西瓜吃夏天22
  • 来源: 51数据库
  • 2023-02-09

问题描述

有没有办法在 Android 上创建特定于应用的软键盘?在阅读了 InputMethodService 文档并查看了替代键盘应用程序之后,我认为替代键盘只能配置为系统范围使用(通过设置 -> 区域设置和文本).

Is there a way to create an app specific soft keyboard on Android? After reading about InputMethodService docs and checking out alternative keyboard apps out there, I figure the alternate keyboard can only be configured for system wide usage (through Settings -> Locale and Text).

如果上述问题的答案是否定的,那么是否至少有一种方法可以加载自定义字典并覆盖系统键盘的默认字典(仅当我的应用程序正在使用时)?当用户只敲击几个键时,这将有助于向用户提供非常相关的建议.

If the answer to above question is no, then is there at least a way to load a custom dictionary and override the default dictionary of the system keyboard (only when my app is in use)? That will help in giving very relevant suggestions to the user when he has only tapped couple of keys.

推荐答案

如果你只想要一个看起来和行为都像软键盘的 View,我在 我的 SmallKeyboard 类.您只需要扩展 android.inputmethodservice.KeyboardView 并决定布局.请参阅该文件末尾的 onKey 和 onText 方法,了解按键被按下时所执行的操作.

If you just want a View that looks and acts like a soft keyboard, I did that in my SmallKeyboard class. You just need to extend android.inputmethodservice.KeyboardView and decide on layout. See the onKey and onText methods at the end of that file for the action taken when keys are pressed.

代替我的键盘模型内部类,您可以从 XML 加载它 如果您的密钥集相当稳定.

Instead of my keyboard model inner class, you could load it from XML if your key set is fairly constant.

软件
前端设计
程序设计
Java相关