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