RatingBar评分控件在Android中经常用到,参考:http://blog.csdn.net/jeff169/article/details/52266155 http://www.cnblogs.com/xgjblog/p/5661301.html
先看下效果图:
这个效果图只是我随便找到的,并不是特定项目中的。
<RatingBar
android:id="@+id/rb_stars"
style="@style/recommand_ratingBar"
android:layout_width="wrap_content"
android:isIndicator="true"
android:stepSize="1"
android:numStars="5"
android:layout_height="wrap_content" />
style:recommand_ratingBar
<style name="recommand_ratingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/ratingbar_recomman_small</item>
<item name="android:minHeight">11dp</item>
<item name="android:maxHeight">11dp</item>
</style>
ratingbar_recomman_small.xml为自定义RatingBar的星星。
<?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/star_32x21_normal"></item>
<item android:id="@android:id/secondaryProgress"
android:drawable="@drawable/star_32x21_normal"></item>
<item android:id="@android:id/progress"
android:drawable="@drawable/star_32x21_checked"></item>
</layer-list>
star_32 X 21_normal star_32 X 21_checked 为自定义的星星图片。