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.

2 Answers 2

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.

3
  • 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, 2013 at 6:27
  • @Aniket: What exception you are getting? Also can you share source code of what you have implemented.
    – dinesh
    Oct 28, 2013 at 6:14
  • Thanks for reply, by the way i got my answer posted below your answer and i posted my exception stackoverflow.com/questions/19464703/…
    – Aniket
    Oct 28, 2013 at 6: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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.