在 Android 中创建自定义键盘

Create Custom Keyboard in Android(在 Android 中创建自定义键盘)
本文介绍了在 Android 中创建自定义键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想编写一个自定义键盘,它应该适用于所有运行 Android 4.0 及更高版本的设备.所以首先我搜索了网络,但没有找到任何相关信息.那么如何创建一个应用来替代 Android 的普通键盘呢?

I'd like to write an custom keyboard which should work on all devices that are running Android 4.0 and up. So first I searched the net but didn't found anything about that. So how can I create an app which replaces the stock keyboard of Android?

我想知道的:

  1. 那里有很好的教程吗?你们有示例代码吗?
  2. 我是否需要 root 才能执行此操作?
  3. 它背后的结构是什么?(它只是一个带有服务的常规活动吗??)
  4. 是否可以读出键盘内的输入框?

推荐答案

所以,当我在 Swype 工作时,我这样做了大约 2 年.你不需要root,你只需要实现一个InputMethodService.您可以从大多数文本框中获取文本,但不是全部(并非所有编辑字段都正确实现了它们的一半 API.尤其是输入类型为 INPUT_TYPE_NULL 的任何内容都无法正常工作).要获取文本,您可以调用 inputConnection.getExtractedText

So, I did this for about 2 years, when I worked on Swype. You don't need root, you just need to implement an InputMethodService. You can get the text out of most textboxes, but not all (not all edit fields correctly implement their half of the APIs. Particularly anything with an input type INPUT_TYPE_NULL will not work well). To get the text you would call inputConnection.getExtractedText

请注意 - API 很糟糕,应用程序在使用它时会受到打击和错过.一个基本的键盘很简单,但是尝试做任何复杂的事情,你会花费很多时间.大键盘花了很多工时

Be warned- the API is bad, and apps are hit and miss on working with it. A basic keyboard is easy, but try and do anything complex and you'll spend a lot of time. A lot of man hours went in to the big keyboards

这篇关于在 Android 中创建自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

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 库时如何抑制警告?)