How can I fill stars in the ratingbar?

160 Views Asked by At

I am trying to add a simple rating bar to my project. I have 3 stars and I want only 2 of them to be filled but it's not working. I have set android : rating = "2" and System.out.printIn(rating.getRating) returns 2 but stars are not filled.

Here is my xml :

<RatingBar
        android:id="@+id/ratingBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/Widget.AppCompat.RatingBar.Small"
        android:isIndicator="true"
        android:numStars="3"
        android:rating="2"
        app:layout_constraintStart_toStartOf="@+id/nom_categorie"
        app:layout_constraintTop_toBottomOf="@+id/nom_categorie" />

I also tried without style, with stepSize = 1 and setRating in Java. Thank you for your help!

1

There are 1 best solutions below

0
Mama On

It is because my App Theme was Theme.MaterialComponents, I changed it to Theme.AppCompat and it worked