1. 资源
android_ratingbar_single_light.png
android_ratingbar_single.png
2. 设置状态
yellow_star_rating_bar_full.xml
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
layer-list
xmlns:android
=
"http://schemas.android.com/apk/res/android"
>
<
item
android:id
=
"@android:id/background"
android:drawable
=
"@drawable/android_ratingbar_single"
/>
<
item
android:id
=
"@android:id/progress"
android:drawable
=
"@drawable/android_ratingbar_single_light"
/>
</
layer-list
>
3. 定义style
<
style
name
=
"yellowStarRatingBar"
parent
=
"@android:style/Widget.RatingBar"
>
<
item
name
=
"android:maxHeight"
>
20.0dip
</
item
>
<
item
name
=
"android:progressDrawable"
>
@drawable/yellow_star_rating_bar_full
</
item
>
<
item
name
=
"android:minHeight"
>
20.0dip
</
item
>
</
style
>
<
RatingBar
android:id
=
"@id/comment_grade_star"
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
android:layout_marginLeft
=
"5.0dip"
android:layout_marginTop
=
"10.0dip"
android:rating
=
"5.0"
android:layout_toRightOf
=
"@id/comment_grade"
android:layout_below
=
"@id/comment_title_name_content"
style
=
"@style/yellowStarRatingBar"
/>
5. 效果图