问题描述
我想编写一个自定义键盘,它应该适用于所有运行 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?
我想知道的:
- 那里有很好的教程吗?你们有示例代码吗?
- 我是否需要 root 才能执行此操作?
- 它背后的结构是什么?(它只是一个带有服务的常规活动吗??)
- 是否可以读出键盘内的输入框?
推荐答案
所以,当我在 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 中创建自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)