Create Custom Keyboard in 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?
我想知道的:
- 那里有很好的教程吗?你们有示例代码吗?
- 我是否需要 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 中创建自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 中创建自定义键盘
基础教程推荐
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
