Sunday, May 22, 2011

How To: Custom Keyboard in Android 3.0(Step 1: Custom Keyboard design)

I think some of you may have same problem in Android 3.0 tablet:

Unable to disable some keys in it's new default Input Method, like "Input Method Options" key and "Voice Input" key.

And we may have other friends that just want to disable the Input Methods in their apps.

This post may help you on how to create a custom keyboard in your own apps.

*NOTE: This post is not telling you how to make a Input Method app*

First, you need to create a new XML file using for custom interface of your keyboard, this is easy on Android SDK because we have a UI Element called "Keyboard".

Here's one sample keyboard interface code:
(Anyone who knows how to paste code as a "code clip" in this blogspot, can tell me)

Here are two important sub elements:

  • Row: each Row here is a new line for your keyboard, you can have as much rows as you want.
  • Key: each Key here is a touch key with touch effects, like a big character box telling you which key is pressed.(Yes, the "Keyboard" element is so good that it already has this!)
You may be puzzling on the codes I'm using. Yes, android SDK has it's full codes list for each keyboard keys, but we are making our own custom keyboard, why we need to follow that unmemorable list?

Using any codes that you think is easier for you to remember.

OK, now you can add your custom keyboard into any place you want, like:

or if you want it always displaying at the bottom:

Now, we have a new keyboard!

Next Step post, we are going to work on activity's code, on display/hide keyboards, and also key press event catch.


  1. is there a way to have both keyboard layouts in one xml file?

    1. find out code from below link

  2. maybe
    in OnCreate()