5

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.

Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96
Aniket
  • 2,204
  • 5
  • 34
  • 51

2 Answers2

1

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.

dinesh
  • 531
  • 2
  • 8
  • hi @dinesh i have already implemented these helps but not getting any response, but when i used onDraw(), i got one exception.. – Aniket Oct 22 '13 at 06:27
  • @Aniket: What exception you are getting? Also can you share source code of what you have implemented. – dinesh Oct 28 '13 at 06:14
  • Thanks for reply, by the way i got my answer posted below your answer and i posted my exception http://stackoverflow.com/questions/19464703/soft-keyboard-getting-nullpointerexception-when-calling-canvas-drawtext – Aniket Oct 28 '13 at 06:18
1

Hi I have done it with by taking reference of Customize the appearance of a <Key>

By playing with given code after three days i have got my solution.

Community
  • 1
  • 1
Aniket
  • 2,204
  • 5
  • 34
  • 51