In Android Custom Keyboard, how to change Alphabets Keyboard to Symbols Keyboard?
Asked Answered
B

1

1

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.

Note: Images shown in below.

I handled Key Actions to Navigate User from Alphabets Keyboard to Symbol Keyboard in the onKey Method

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: enter image description here

While Change Keyboard in KeyboardView using setMethod in Kotlin, It changes with some mild UI Error

Symbols Keyboard: enter image description here

Note:

  • Symbols Keyboard has no issue. Bcz We tried to have it as a Primary Keyboard to inflate at very first time. It has no issue at that time.
  • Issue is in Keyboard Change portion (onKey Method). Alphabets Keyboard also not fully compatible while changing Keyboard
Bombardier answered 28/12, 2018 at 13:8 Comment(2)
I am having the same issue, did you ever figure this out?Macmullin
@Macmullin Please refer this #53959615Bombardier
B
1

Keyboard Layout draws every key based on the percentage not in dp. So declare your key width as %p not in 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>
Bombardier answered 27/1, 2020 at 15:52 Comment(2)
Can you provide the list of keycodes for symbols for the keyboardFaviolafavonian
@Faviolafavonian developer.android.com/reference/android/view/KeyEvent#KEYCODE_0Sanderling

© 2022 - 2024 — McMap. All rights reserved.