android - 键盘背景状态

标签 android background keyboard

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/key" />
<item
android:state_pressed="true"
android:drawable="@drawable/key_pressed" />
<item
android:state_checkable="true"
android:drawable="@drawable/key_function" />
<item
android:state_checkable="true"
android:state_pressed="true"
android:drawable="@drawable/key_pressed" />
<item
android:state_checkable="true"
android:state_checked="true"
android:drawable="@drawable/key_function" />
<item
android:state_checkable="true"
android:state_checked="true"
android:state_pressed="true"
android:drawable="@drawable/key_pressed" />
</selector>

测试结果:

普通键 ->@drawable/key

普通按键按下 ->@drawable/key_pressed

粘滞键->@drawable/key_function

按下粘滞键 ->@drawable/key_function <---问题出在这里

最佳答案

The selection is not based on the "best match," but simply the first item that meets the minimum criteria of the state.

http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

所以它是错误的可绘制对象,因为其中一个状态与当前状态匹配

<item
android:state_checkable="true"
android:drawable="@drawable/key_function" />  
<item
android:state_checkable="true"
android:state_checked="true"
android:drawable="@drawable/key_function" />

尝试放

<item
android:state_checkable="true"
android:state_checked="true"
android:state_pressed="true"
android:drawable="@drawable/key_pressed" />

在顶部或为以前的案例添加标准。

关于android - 键盘背景状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12342357/

相关文章:

c++ - Qt C++ 隔离键盘

java - gson.JsonSyntaxException : java. lang.IllegalStateException:

安卓磨损 : launching an activty in the handheld on clicking notification action button in wear

css - Iphone 上奇怪的背景图像和边框错误

javascript - 键盘导航 : how to go to the next and previous element with arrow keys?

ios 使用自定义键盘插入自定义表情符号图标

java - 我无法在离线时正确访问缓存的图像

java - ViewFlipper的具体布局

jquery 褪色 图片

css - 无法使用 CSS 更改正文背景