1、首先在布局中引用星级评分条:
<RatingBar
android:id="@+id/room_ratingbar"
style="@style/roomRatingBar"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
2、定义上一步中用到的 style:
<style name="roomRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/room_rating_bar</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
3、定义第二步中用到的 drawable:
<?xml version="1.0" encoding="utf-8"?>
<!--
This is the rating bar drawable that is used to show a room num.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 未选择 -->
<item android:id="@+android:id/background"
android:drawable="@drawable/room_unselect"></item>
<!-- 半星 -->
<item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/room_unselect"></item>
<!-- 整星 -->
<item android:id="@+android:id/progress"
android:drawable="@drawable/room_select"></item>
</layer-list>