Hi i am working on android soft keyboard. Normally labels displayed on keys are single character as shown below
the above one is done by just using keylabel attribute of Key tag in Keyboard to display whatever text we want on the key. But now my requirement is to display multiple characters on single key as shown below
I got one solution to this by using android:keyIcon but limitation is I need the color of characters to be configurable so that a user can change color of any character. Like 1 with red, | with blue, q with green. So it must be configurable to any color.That's why I skipped keyIcon property for displaying text on character.
So is there any way to set multiple characters on key.
The standard KeyboardView provided by android framework doesn't support displaying secondary text (or multiple characters). To achieve your desired functionality you need to subclass the KeyboardView(or simply View) and implement its onDraw method and draw directly to the Canvas.
You can check the source code of latinIME KeyboardView where its been implemented using hint label. Also you need to write your own parser for parsing the Keyboard xml. you can check here how its done in LatinIME.
Understanding the complete package Keyboard in LatinIME will be very helpful for your requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With