<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>
test result:
normal key ->@drawable/key
normal key pressed ->@drawable/key_pressed
Sticky key->@drawable/key_function
Sticky key pressed ->@drawable/key_function <—here is the problem
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
So it’s the wrong drawable because one of those states is matching the current state
Try to put
at the top or add criterias to the previous cases.