ImageView设置selector不起作用
fixed:selector会从上往下选择状态,哪个先符合就先选哪个。
问题代码:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
//默认状态放在了第一行,所以不会起作用
<item android:drawable="@drawable/unselected" android:state_checked="false"/>
<item android:drawable="@drawable/selected" android:state_selected="true" />
<item android:drawable="@drawable/selected" android:state_checked="true" />
</selector>
修正后代码:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/selected" android:state_selected="true" />
<item android:drawable="@drawable/selected" android:state_checked="true" />
<item android:drawable="@drawable/unselected" android:state_checked="false"/>
</selector>