![](/img/trans.png)
[英]When I use custom stars for Android RatingBar, always show half star for decimal values below 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" />
上面的代码将显示半颗星。 但是据我所知,它应该吸引一颗星。
PS我尝试过以编程方式实现它,但还是一样。
我通过将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"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.