在 Android 中创建自定义键盘 [英] Create Custom Keyboard in Android

查看:27
本文介绍了在 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 中创建自定义键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆