安卓键盘按键预览背景图片

标签 android image background keyboard preview

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

最佳答案

如果您通过扩展 KeyboardView 创建自定义键盘,那么我们可以使用 'android:keyPreviewLayout' 属性为我们的自定义 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"/>

希望这对您有所帮助!

关于安卓键盘按键预览背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12211615/

相关文章:

android - 我们如何设置列的内容以在表格布局中换行

html - 带有图像和文本的链接 - 组合还是单独?

javascript - 创建裁剪图像幻灯片

android - 而循环 : Change Background color

android - ListView 选择问题...使用 onItemClick(AdapterView<?> parent, View view, ...)

android - 小部件中的动画 .png 图像

android - 如何通过单击按钮从大约返回到上一个 Activity ?

java - Android获取ImageButton的背景资源

html - 在背景上定位图像(背景大小变化)

CSS:背景图像不透明的背景颜色