简体   繁体   English

是否可以在不使用 xml 的情况下完全用 Java 制作 android 键盘

[英]Is it possible to make an android keyboard entirely out of Java without using xml

I would like to create an android keyboard as much as possible only using Java.我想尽可能只使用 Java 创建一个 android 键盘。

I am familiar with the traditional android keyboard app setup - xml files for each keyboard 'page' and hardcoded key sizes etc.我熟悉传统的 android 键盘应用程序设置 - 每个键盘“页面”的 xml 文件和硬编码键大小等。

I want a lot of customization in my keyboard with the ability to use JSON as a data source for whole keyboard layouts generated with Java.我希望在我的键盘中进行大量自定义,并能够使用 JSON 作为使用 Java 生成的整个键盘布局的数据源。

Has it been done before or am I dreaming?是以前做过还是我在做梦?

Of course it is.当然是这样。 Any UI can be made without an xml file- you can always create views with new and manually add them to a parent.任何 UI 都可以在没有 xml 文件的情况下制作 - 您始终可以使用 new 创建视图并手动将它们添加到父级。

Did you mean doing it without using KeyboardView?你的意思是不使用 KeyboardView 来做吗? Yes, you can do that too.是的,你也可以这样做。 KeyboardView is meant as a convenience for very simple keyboards, no real keyboard app uses it- not even google's keyboard. KeyboardView 旨在为非常简单的键盘提供便利,没有真正的键盘应用程序使用它 - 甚至谷歌的键盘也没有。 In the InputMethodService's onCreateInputView, return whatever view you wish to use.在 InputMethodService 的 onCreateInputView 中,返回您希望使用的任何视图。 Any view can be returned.任何视图都可以返回。 So you can be as flexible as you want.因此,您可以随心所欲。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM