test

android评分条RatingBar自定义设置

页面XML文件:

<RatingBar 
         android:id="@+id/ratingbarId"
         style="@style/MyRatingBar"                - - 引用style XML文件 "name"为MyRatingBar
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:numStars="5"
         android:stepSize="1.0"/>

 

style XML文件:

<resources>        
        <style name="MyRatingBar" parent="@android:style/Widget.RatingBar">     
        <item name="android:progressDrawable">@drawable/rating_bar_full</item>     
        <item name="android:minHeight">22dip</item>         - - 评分条最小高度和最大高度调整 
        <item name="android:maxHeight">25dip</item>     
    </style>     
</resources>

 

rating_bar_full XML文件:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">     
    <item android:id="@+android:id/background"          - - 背景星 
          android:drawable="@drawable/star1" />     
    <item android:id="@+android:id/secondaryProgress"        - - 背景星
          android:drawable="@drawable/star1" />     
    <item android:id="@+android:id/progress"          - - 变化

          android:drawable="@drawable/star2" />     
</layer-list>

posted @ 2014-09-26 10:56  Lechance  阅读(275)  评论(0编辑  收藏  举报