Android:评分栏步长低于 0.5

Android: Ratingbar stepsize below 0.5

我已经在我的代码中添加了一个 RatingBar,除了一件事,它运行良好。我试图将步长设置为 0.1,但它仍然根据默认的 0.5 步长做出反应。我可以轻松地将步长设置为高于 0.5,它会按预期做出反应但不会降低。

我不明白为什么?我唯一能想到的是 RatingBar 的步长上限为 0.5?对于 RatingBar 最少绘制半颗星,哪个没有意义?

<android.support.v7.widget.AppCompatRatingBar
    android:theme="@style/RatingBar"
    android:stepSize="0.1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/ratingbar"
    android:numStars="5"
    android:rating="0.1"
    style="?android:attr/ratingBarStyleSmall"
    android:layout_below="@+id/title"
    android:layout_centerHorizontal="true" />

以上代码会显示半颗星。不过据我所知,应该是抽星的十分之一。

P.S 我试过以编程方式实现它,但还是一样。

我通过将 secondaryProgressTint 设置为透明的 #00000000 来解决此问题。

secondaryProgressTint 填充剩余的开始星数。默认的颜色显然设置为与您的主要 progressTint 相同的颜色,因此如果您不知道会造成很多混乱。

<android.support.v7.widget.AppCompatRatingBar
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/ratingbar"
           style="?android:attr/ratingBarStyleSmall"
           android:isIndicator="true"
           android:progressTint="@color/Red"
           android:secondaryProgressTint="#00000000"
           android:numStars="5"
           android:rating="3.3"
           android:stepSize="0.1"
           android:layout_below="@+id/title"
           android:layout_centerHorizontal="true"
            />