问题描述
我想编写一个自定义的键盘它应该可以运行的Android 4.0及以上的所有设备。所以首先我搜索网,但并没有发现有关的事情。所以,我怎么可以创建一个应用程序,它取代了股票键盘的Android?
我想知道的:
- 有一个很好的教程在那里?难道你们有样本code?
- 请我需要root做到这一点?
- 什么是它背后的结构? (难道只是一个服务??一个普通的活动)
- 是否有可能在键盘中读出的输入框?
所以,我这样做了约2年,当我的工作了Swype。您不需要根,你只需要实现一个InputMethodService。您可以获取文本掉大部分文本框,但不是所有的(不是所有的编辑字段正确地实现其一半的API,特别具有输入型INPUT_TYPE_NULL很少会无法正常工作)。为了获取文本,你会打电话inputConnection.getExtractedText
要warned-的API是坏的,和应用程序是碰运气与它的工作。一个基本的键盘很容易,但尝试做任何事情复杂,你会花大量的时间。很多工时去到大键盘
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?
What I'd like to know:
- Is there a good tutorial out there? Do you guys have sample code?
- Do I need root to do this?
- What's the structure behind it? (Is it just a regular Activity with a Service??)
- Is it possible to read out the Inputbox within the keyboard?
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
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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!