安卓应用专用软键盘

android app specific soft keyboard(安卓应用专用软键盘)
本文介绍了安卓应用专用软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

有没有办法在 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.

这篇关于安卓应用专用软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)