3

开发安卓键盘:如何更改按键预览的背景图像?

4

1 回答 1

5

如果您通过扩展 KeyboardView 创建自定义键盘,那么我们可以使用 'android:keyPreviewLayout' attr 为我们的自定义 KeyboardView 设置自定义键预览布局。

例如

 <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" />

其中 my_custom_layout.xml 是您的自定义预览布局,例如

<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"/>

希望这可以帮助!

于 2012-09-04T18:38:20.433 回答