Reputation: 89
DEVELOPING AN ANDROID KEYBOARD: how can I change the background image of the key preview?
Upvotes: 3
Views: 3245
Reputation: 196
If you are creating your custom keyboard by extending KeyboardView then we can set a custom key preview layout to our custom KeyboardView using 'android:keyPreviewLayout' attr.
E.g.
<com.example.myApp.MyCustomKeyboardView
android:id="@+id/keyboard_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:keyPreviewLayout="@layout/my_custom_layout" />
where my_custom_layout.xml is your custom preview layout something like
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80sp"
android:textSize="40sp"
android:textColor="?android:attr/textColorPrimaryInverse"
android:minWidth="32dip"
android:gravity="center"
android:background="@color/black"/>
Hope this helps!
Upvotes: 5