Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the colors of Android small RatingBar

I am trying to set a custom color for the small progressbar with this code:

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

The problem with this is this: the stars are small quite alright but they are blue. But If I remove style="@android:style/Widget.Holo.Light.RatingBar.Small then the color becomes golden yellow but it becomes big.

Please how do I set custom colors for the stars and at the same time make it small?

like image 576
X09 Avatar asked Dec 05 '22 17:12

X09


1 Answers

Use style="?attr/ratingBarStyleSmall" 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="?attr/ratingBarStyleSmall"/>

see also: https://stackoverflow.com/a/3173594/5183999

like image 104
nshmura Avatar answered Dec 10 '22 13:12

nshmura