RatingBar自定义样式


首先给个效果图出来吧,我觉得图片UI做的好,显示出来就漂亮:

2个背景图为:


主要就是这样一个Style:
<RatingBar
        android:id="@+id/volume_ratingBar"
        style="@style/wmtRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:numStars="5"
        android:paddingBottom="20dip"
        android:paddingTop="20dip" >
    </RatingBar>


styles.xml:
<style name="wmtRatingBar" parent="@android:style/Widget.RatingBar">
        <item name="android:progressDrawable">@drawable/wmt_ratingbar</item>
        <item name="android:minHeight">40dp</item>
        <item name="android:maxHeight">50dp</item>
    </style>



wmt_ratingbar.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/wmt_ratingbar_off"></item>

    <item
        android:id="@+android:id/secondaryProgress"
        android:drawable="@drawable/wmt_ratingbar_off"></item>

    <item
        android:id="@+android:id/progress"
        android:drawable="@drawable/wmt_ratingbar_on"></item>

</layer-list>


你可能感兴趣的:(RatingBar)