我的设置:
selector:
error:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/icon_attendance_record"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_checked="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_pressed="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_active="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_focused="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_checkable="true"/></selector>
right:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/icon_attendance_record_press" android:state_checked="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_pressed="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_active="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_focused="true"/> <item android:drawable="@drawable/icon_attendance_record_press" android:state_checkable="true"/> <item android:drawable="@drawable/icon_attendance_record"/></selector>
you can see:
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
During each state change, the state list is traversed top to bottom and the first item that matches the current state is used—the selection is not based on the "best match," but simply the first item that meets the minimum criteria of the state.
这里的每一个Item的改变,Android 会从第一个Item,寻找匹配当前的状态的Item.然后设置!
如果,讲Normal 放到第一个 就会一直匹配第一个!
No comments:
Post a Comment