【问题标题】:How to set the colors of Android small RatingBar如何设置Android小RatingBar的颜色
【发布时间】:2016-12-27 20:37:41
【问题描述】:

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

<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,那么颜色会变成金黄色,但会变大。

请问如何为星星设置自定义颜色并同时使其变小?

【问题讨论】:

    标签: android ratingbar


    【解决方案1】:

    使用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://stackoverflow.com/a/3173594/5183999

    【讨论】:

    • 谢谢!你做到了!正因为如此,我已经挣扎了三个多小时。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 2011-04-09
    • 2011-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多