如何设置Android小型评分条的颜色

4

我尝试使用以下代码为小进度条设置自定义颜色:

<style name="RatingBar" parent="Theme.AppCompat">
        <item name="colorControlNormal">@color/gold_yellow</item>
        <item name="colorControlActivated">@color/light_grey</item>
    </style>




<RatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:isIndicator="true"
        android:rating="3.3"
        android:theme="@style/RatingBar"
        android:id="@+id/go_rating"
        style="@android:style/Widget.Holo.Light.RatingBar.Small"/>

这个问题在于:星星确实很小,但它们是蓝色的。但是如果我删除style="@android:style/Widget.Holo.Light.RatingBar.Small,那么颜色会变成金黄色,但它会变得更大。
请问如何设置星星的自定义颜色并使其保持小尺寸?
1个回答

16

使用 style="?attr/ratingBarStyleSmall" 样式:

<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:isIndicator="true"
    android:rating="3.3"
    android:theme="@style/RatingBar"
    android:id="@+id/go_rating"
    style="?attr/ratingBarStyleSmall"/>

参见:https://dev59.com/-XE85IYBdhLWcg3wPA98#3173594


谢谢!你做到了!我因为这个问题已经挣扎了3个多小时。谢谢! - X09

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接