I’m building a custom keyboard in android.
My input.xml:
<com.mykeyboard.MyKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyBackground="@drawable/keybg"
/>
All the keys do have the same background.
Now I’m trying to dynamically change the background of one single key.
Is this possible?
The code for my custom MyKeyboardView can be found here:
http://pastebin.com/ZpLzZZUj
The code for my MyKeyboardService can be found here:
http://pastebin.com/HYPGFTfg
Just because you have extended from KeyboardView doesn’t mean that you can easily pick a Key and change the way it is drawing.
The source of the KeyboardView and especially the for-loop starting in line 678 are showing how complex the drawing of a keyboard can be.
What you can do: override the onDraw() method, call super.onDraw() and than get the key you want and draw again only this key. You probably need a lot of customizing and probably a lot of copy&paste of the original code to get something done.
Main question: Is this work really necessary? I personally wouldn’t want some app to change my well-known keyboard look&feel (as long as it isn’t a real custom keyboard app :D)