小智 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" />
Run Code Online (Sandbox Code Playgroud)
其中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"/>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!