在drawable裏面新建一個xml的文件,
裏面寫上:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/dirtyclothes_true_new" android:state_pressed="true"/> <item android:drawable="@mipmap/dirtyclothes_false_new" android:state_focused="false" android:state_pressed="false"/> <item android:drawable="@mipmap/dirtyclothes_true_new" android:state_focused="true"/> <item android:drawable="@mipmap/dirtyclothes_false_new" android:state_focused="false"/> </selector>
在imageview的background裏面用這個xml就可以。