【问题标题】:Android keyboard key preview background imageAndroid键盘按键预览背景图片
【发布时间】:2012-08-31 08:32:03
【问题描述】:

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

【问题讨论】:

标签: android image background keyboard preview


【解决方案1】:

如果您通过扩展 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"/>

希望这会有所帮助!

【讨论】:

  • 感谢 evr,这与我想要的非常接近。我只是将颜色更改为图像并且不需要这些值:android:background="@drawable/preview"
  • 我想在 My Key 的 LongPress 事件上更改 keyPreviewLayout 可以吗??
猜你喜欢
  • 1970-01-01
  • 2013-12-16
  • 2016-12-03
  • 2013-03-25
  • 2017-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-15
相关资源
最近更新 更多