嘿嘿,我们很多时候不会用星星作为评分标准的,我们来改改呗~把星星改成其他的,比如笑脸,两个素材:
接下来和前面的SeekBar一样编写一个layer-list的文件:
ratingbar_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="@mipmap/ic_rating_off1" /> <item android:id="@android:id/secondaryProgress" android:drawable="@mipmap/ic_rating_off1" /> <item android:id="@android:id/progress" android:drawable="@mipmap/ic_rating_on1" /> </layer-list>
接着在style.xml中自定义下RatingBar Style,在style.xml加上这个:
<style name="roomRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/ratingbar_full</item> <item name="android:minHeight">24dip</item> <item name="android:maxHeight">24dip</item> </style>
最后在布局中的Ratingbar组件设置下:
<RatingBar android:id="@+id/rb_normal" style="@style/roomRatingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" />
运行效果图: