使用level实现图片切换
res/drawable/comment_like_level.xml
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/ic_dianzan"
android:maxLevel="0"/>
<item
android:drawable="@drawable/ic_yidianzan"
android:maxLevel="1"/>
</level-list>
activity_main.xml
<ImageView
android:id="@+id/iv_comment_zan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="-2dp"
android:src="@drawable/comment_like_level"/>
MainActivity.java
if (listDatas.get(position).isPrase) {
holder.iv_zan.setImageLevel(1);
} else {
holder.iv_zan.setImageLevel(0);
}