2

I want to change colour of RatingBar stars in every mode(highlighted, notHighlited, progress), but I already use style Widget.AppCompat.RatingBar.

I don't want to change style cause, I like star shapes and staff, I only want to change star colors, Is it possible?

Here's my code:

<RatingBar
        android:id="@+id/ratingBar"
        style="@style/Widget.AppCompat.RatingBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numStars="5"
        android:stepSize="1.0"
        android:layout_gravity="center_horizontal"
        android:rating="0.0" />
Nikoloz14
  • 207
  • 4
  • 13

1 Answers1

3

Use styles:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background" android:drawable="@drawable/background" />
    <item android:id="@android:id/secondaryProgress" android:drawable="@drawable/secondary_progress" />
    <item android:id="@android:id/progress" android:drawable="@drawable/progress" />
</layer-list>

You can use this style following way. Add this line to the RatingBar:

android:progressDrawable="@drawable/rating"
Nikoloz Akhvlediani
  • 403
  • 1
  • 4
  • 19