Avinash Jaiswal Avinash Jaiswal - 1 month ago 17
Android Question

How to set rating bar star color to a single color in all the devices?

I am trying to set the rating bar star color to a single color in all the devices. Currently I am setting the star color using style definition in styles.xml, but it is not working. Please help me out guys.
Regards,
Thanks.

Answer

Example (from my own app):

<RatingBar
        android:id="@+id/rating"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numStars="5"
        android:stepSize="1"
        android:theme="@style/RatingBar"/>

With theme:

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