但是当触摸(并按住)它们时,所有未评级的星星都是粉红色的,像这样
为什么会这样?
xml:
<RatingBar
android:id="@+id/ratingBarSchedulesRatingTour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:numStars="5"
android:progressTint="@color/yellow_star"
android:secondaryProgressTint="@color/yellow_star"
android:stepSize="1" />
@@ color / yellow_star在colors.xml上为#F1CD1E
根据需要创建样式和颜色(按/正常)
<style name="RatingBar" parent="Theme.AppCompat">
<item name="colorControlNormal">#F1CD1E</item>
<item name="colorControlActivated">#F1CD1E</item>
</style>
<RatingBar
android:id="@+id/ratingBarSchedulesRatingTour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:numStars="5"
android:progressTint="#F1CD1E"
android:theme="@style/RatingBar"
android:secondaryProgressTint="#F1CD1E"
android:stepSize="1" />
您可以在android:progressBackgroundTint
上使用RatingBar
属性覆盖背景色:
android:progressBackgroundTint="#ABABAB"