RatingBar持有时为粉红色背景

问题描述 投票:0回答:2

我的RatingBar非常正常,当选择时显示为enter image description here

但是当触摸(并按住)它们时,所有未评级的星星都是粉红色的,像这样

enter image description here

为什么会这样?

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

android android-studio ratingbar
2个回答
0
投票

根据需要创建样式和颜色(按/正常)

<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" />

0
投票

您可以在android:progressBackgroundTint上使用RatingBar属性覆盖背景色:

android:progressBackgroundTint="#ABABAB"
© www.soinside.com 2019 - 2024. All rights reserved.