[英]Android RatingBar rating is not set correctly
我在xml布局中使用了兩個RatingBars:
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.25"
android:rating="4.25"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.25"
android:rating="4.5"/>
即使我將等級設置為4.25和4.5 ,兩個RatingBars都顯示錯誤的滿星數量。 在Android 6設備上,它看起來像這樣:
在android 4.3設備上,它看起來像這樣:
但是在xml設計視圖上,我可以看到設置了4.25和4.5。 誰能告訴我為什么? 我對代碼中的評分欄不做任何操作。
謝謝。
我認為問題與android:progressTint ,android:progressBackgroundTint & android:secondaryProgressTint
。 嘗試將以下幾行添加到您的評分欄中:
android:progressTint="Color1"
android:progressBackgroundTint="Color2"
android:secondaryProgressTint="Color3"
也嘗試將樣式添加到評分欄,如下所示:
<style name="RatingBar" parent="Theme.AppCompat"">
<item name="colorControlNormal">@color/yourColor1</item>
<item name="colorControlActivated">@color/yourColor2</item></style>
最后在評分欄中添加以下行
style="@style/RatingBar"
它將為您工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.