[英]RatingBar change star value rating worth
我正在使用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" />
我认为您可以这样做:
<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
都是半颗星星,并且等级8 * stepSize
将仅填充4个星星而不是5个星星。
一行:
ratingBar.setRating(8 * stepSize);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.