如何为Android应用程序开发自定义软键盘?
我制作了一个与数学相关的应用程序,我真的很想为其制作一个自定义软键盘。它将具有数字键盘等属性以及内置的特殊字符(例如 pi 和平方根符号)。我希望它仅替换为该应用程序的默认键盘,并且仅打开我为此应用程序开发的键盘。我的问题是我该怎么做?我是用表格布局和一堆在单击文本字段时打开的按钮制作一个“键盘”,还是使用键盘布局?
I've got an Math related application I've made that I really would like to make a custom soft keyboard for. It would have attributes like a numpad and special characters like pi and square root symbols built in. I would want it to replace to default keyboard just for that application, and only open the keyboard that I develop for this app. My question is how do I do that? Do I make a "keyboard" out of table layouts and a bunch of buttons that opens when I click on the text field, or do I make use of the keyboard layout?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该创建表格布局和一堆按钮,这是一个不熟悉的用户界面,并且会产生糟糕的用户体验。请参阅此答案,了解如何创建与平台软键盘相同但包含您需要的按键的自定义软键盘:Android 应用程序特定软键盘
You should not create a table layout and a bunch of buttons, it is an unfamiliar user interface and creates a bad user experience. See this answer about how to create a custom soft keyboard that is identical to the platform soft keyboard but contains the keys you need: android app specific soft keyboard
您可以制作一个相对布局,在屏幕底部有像键盘一样的按钮行(使用线性布局),或者如果您需要一个系统范围的键盘,我会看看 Hackerskeyboard 示例源。
You could make a RelativeLayout, with rows of buttons like a keyboard at the bottom of the screen(using Linear layouts), or if you need to have a system wide keyboard, I'd look at Hackerskeyboard source for an example.