在android中更改评级栏的图像

时间:2016-05-18 12:44:21

标签: java android xml android-layout ratingbar

我想为每个评级使用自定义评级栏图标,如下图所示。我希望用户选择1到10之间的评级。 enter image description here

现在我尝试使用以下代码:

        <com.whinc.widget.ratingbar.RatingBar
            android:id="@+id/ratingBars"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            app:rb_max_count="10"
            app:rb_count="1"
            app:rb_empty="@drawable/empty"
            app:rb_fill="@drawable/fill"
            app:rb_space="20dp"
            app:rb_click_rating="true"
            app:rb_touch_rating="true"/>

但我只能改变完整的图像而不是个人。请建议

1 个答案:

答案 0 :(得分:0)

使用android:stepSize="0.1"&amp; android:numStars="10"如下所示:

  <RatingBar
                android:id="@+id/rating"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                style="?android:attr/ratingBarStyleSmall"
                android:numStars="10"
                android:stepSize="0.1"
                android:isIndicator="true" />