RatingBar 自定义style的用法

第一步:配置ratingbar 的style

<style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
  <item name="android:progressDrawable">@drawable/food_ratingbar_full</item>
  <item name="android:minHeight">48dip</item>
    <item name="android:maxHeight">48dip</item>
</style>

第二部:配置 drawable

<?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/fans_mark_gray" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/fans_mark_gray" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/fans_mark_red" />
</layer-list>

第三部:引用 style

<RatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"       
        android:numStars="5"//star 数量
        android:stepSize="1" //如果可以交互 每次的增量
        android:isIndicator="false"//true 不可交互
        android:rating="2"                 //默认 进度2
       style="@style/foodRatingBar"       
         />

 

 

posted @ 2012-07-13 16:22  lipeil  阅读(5161)  评论(0编辑  收藏  举报