android:focusable=“true”
android:focusableInTouchMode=“true”
android:keyBackground="@drawable/bg_keyboard_selector"
android:keyTextColor="@color/keyTextColor"
android:visibility=“gone”
android:keyPreviewLayout="@layout/key_preview_layout"
/>
- 其中
android:keyPreviewLayout
指的是每当我们点击键盘上的某个键时,短暂弹出的布局。
| 属性名 | 描述 |
| — | — |
| android:keyBackground | Image for the key. |
| android:keyPreviewLayout | Layout resource for key press feedback. |
| android:keyPreviewOffset | Vertical offset of the key press feedback from the key. |
| android:keyTextColor | Color to use for the label in a key. |
| android:keyTextSize | Size of the text for character keys. |
| android:labelTextSize | Size of the text for custom keys with some text and no icon. |
| android:popupLayout | Layout resource for popup keyboards. |
| android:verticalCorrection | Amount to offset the touch Y coordinate by, for bias correction. |
- 我们需要建一个
xml文件
,来布局我们的视图,
一般是在res
文件夹中建一个名为xml的文件夹,在里面新建立一个xml布局文件。
- 每一个按键的属性主要包括
android:codes=" " 和 android:keyLabel=""
Activity
就是根据 codes
的值来监听的。
一些可以自定义设置,一些需要是 keyboard
中设置好的,要保持一致。
二、实例解析:在xml文件中定义