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
Vivek
  • 113
  • 1
  • 12
  • I am having the same issue, did you ever figure this out? – Jayce Dec 17 '19 at 20:02
  • @Jayce Please refer this https://stackoverflow.com/questions/53959115/in-android-custom-keyboard-how-to-change-alphabets-keyboard-to-symbols-keyboard/59934561#59934561 – Vivek Jan 27 '20 at 15:53

1 Answers1

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>
Vivek
  • 113
  • 1
  • 12