[英]In Android Custom Keyboard, how to change Alphabets Keyboard to Symbols Keyboard?
While Navigate User from Alphabets Keyboard to Symbols Keyboard, Layout Alignment gets spoiled.在将用户从字母键盘导航到符号键盘时,布局对齐被破坏了。 By Default, Layout takes 5dp padding & User can't see the Last Column Keys.默认情况下,布局采用 5dp 填充,用户看不到最后一列键。
Note: Images shown in below.注:图片如下所示。
I handled Key Actions to Navigate User from Alphabets Keyboard to Symbol Keyboard in the onKey Method我在 onKey 方法中处理了将用户从字母键盘导航到符号键盘的关键操作
override fun onKey(primaryCode: Int, keyCodes: IntArray?) {
when (primaryCode) {
KEYCODE_ALPHABETS -> {
keyboardView?.keyboard = Keyboard(this, R.xml.keyboard)
}
KEYCODE_SYMBOLS_1 -> {
keyboardView?.keyboard = Keyboard(this, R.xml.keyboard_symbols_1)
}
KEYCODE_SYMBOLS_2 -> {
keyboardView?.keyboard = Keyboard(this, R.xml.keyboard_symbols_2)
}
}
} }
Pls Suggest is there any other way to change keyboard (or) what I've done wrong请建议有没有其他方法可以更改键盘(或)我做错了什么
What I faced is shown below.我遇到的情况如下所示。 Alphabets Keyboard:字母键盘:
While Change Keyboard in KeyboardView using setMethod in Kotlin, It changes with some mild UI Error在 Kotlin 中使用 setMethod 在 KeyboardView 中更改键盘时,它会随着一些轻微的 UI 错误而改变
Note:笔记:
Keyboard Layout draws every key based on the percentage not in dp .键盘布局根据不在dp中的百分比绘制每个键。 So declare your key width as %p not in dp所以声明你的键宽为%p而不是dp
In Layout file在布局文件中
<Row
android:horizontalGap="@fraction/key_horizontal_ten_keys_gap"
android:keyWidth="@fraction/ten_keys_key_width"
android:rowEdgeFlags="top">
</Row>
In Resource file在资源文件中
<fraction name="ten_keys_key_width">8.8%p</fraction>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.