RatingBar更改星级评级值

时间:2018-05-09 22:27:55

标签: android android-layout ratingbar

我正在使用Android SDK RatingBar并尝试做5颗星,其中每颗星的价值为2,但它不起作用。我想要评级" 8"只填4星,但它填满了所有5.我需要使用第三方库来解决这个问题吗?

 <RatingBar
      android:id="@+id/user_rating_bar"
      android:isIndicator="true"
      android:rating="8"
      android:stepSize="0.01"
      android:max="10"
      android:numStars="5"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

1 个答案:

答案 0 :(得分:0)

我认为你可以这样做:

<RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:stepSize="0.5"
    android:rating="2.5"
    android:numStars="5"
    />

如果您使用stepSize值为0.5的5颗星,则需要10个步骤才能填充,这样每个0.5都是半星,评分为{{1只填充4星而不是5星。

在一行中:

8 * stepSize
相关问题