Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display multiline/multiple characters as key label on soft keyboard keys

Hi i am working on android soft keyboard. Normally labels displayed on keys are single character as shown below

enter image description here

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

enter image description here

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.

like image 436
Aniket Avatar asked Nov 01 '22 12:11

Aniket


1 Answers

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.

like image 144
dinesh Avatar answered Nov 15 '22 04:11

dinesh