點擊imageview圖片切換(只在點擊的時候)

在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就可以。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章