[英]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.