Android 技术总结(020)—— level-list的使用
1、资源文件。
level_credit_rating.xml
[html]
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/icon_seller_credit_level_first1"
android:maxLevel="1"/>
<item
android:drawable="@drawable/icon_seller_credit_level_first2"
android:maxLevel="2"/>
<item
android:drawable="@drawable/icon_seller_credit_level_first3"
android:maxLevel="3"/>
<item
android:drawable="@drawable/icon_seller_credit_level_first4"
android:maxLevel="4"/>
<item
android:drawable="@drawable/icon_seller_credit_level_first5"
android:maxLevel="5"/>
<item
android:drawable="@drawable/icon_seller_credit_level_second1"
android:maxLevel="6"/>
<item
android:drawable="@drawable/icon_seller_credit_level_second2"
android:maxLevel="7"/>
<item
android:drawable="@drawable/icon_seller_credit_level_second3"
android:maxLevel="8"/>
<item
android:drawable="@drawable/icon_seller_credit_level_second4"
android:maxLevel="9"/>
<item
android:drawable="@drawable/icon_seller_credit_level_second5"
android:maxLevel="10"/>
<item
android:drawable="@drawable/icon_seller_credit_level_third1"
android:maxLevel="11"/>
<item
android:drawable="@drawable/icon_seller_credit_level_third2"
android:maxLevel="12"/>
<item
android:drawable="@drawable/icon_seller_credit_level_third3"
android:maxLevel="13"/>
<item
android:drawable="@drawable/icon_seller_credit_level_third4"
android:maxLevel="14"/>
<item
android:drawable="@drawable/icon_seller_credit_level_first5"
android:maxLevel="15"/>
<item
android:drawable="@drawable/icon_seller_credit_level_fourth1"
android:maxLevel="16"/>
<item
android:drawable="@drawable/icon_seller_credit_level_fourth2"
android:maxLevel="17"/>
<item
android:drawable="@drawable/icon_seller_credit_level_fourth3"
android:maxLevel="18"/>
<item
android:drawable="@drawable/icon_seller_credit_level_fourth4"
android:maxLevel="19"/>
<item
android:drawable="@drawable/icon_seller_credit_level_fourth5"
android:maxLevel="20"/>
</level-list>
2、在布局文件中使用。
[html]
<ImageView
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"
android:layout_marginTop="6dip"
android:src="@drawable/level_credit_rating" />
3、在代码中使用。
[java] view plaincopy
holder.rating.setImageLevel(record.getCreditRating());
补充:移动开发 , Android ,