0

Currently I'm developing an app which uses the RatingBar. I accidentally changed some styling values and now my RatingBar has some kind of stroke on it.

1 http://qs.lc/3ns3n

Like this.

I know this is a really silly question but I just can't remove it haha. Thank you!

<RatingBar android:layout_width="146dp"
    android:layout_height="wrap_content"
    style="?android:attr/ratingBarStyleSmall"
    android:id="@+id/card_main_inner_ratingbar"
    android:stepSize="1" android:numStars="10" /> 
Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
Reverb
  • 53
  • 1
  • 6

3 Answers3

0

I had the same problem and I solved it by setting the layout_width and the layout_height with only wrap_content

Imene Noomene
  • 3,035
  • 5
  • 18
  • 34
0

Create a selector file in the drawable folder:

custom_ratingbar_selector.xml

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

 <item android:id="@android:id/secondaryProgress"
    android:drawable="@drawable/star_off" />

 <item android:id="@android:id/progress"
    android:drawable="@drawable/star_on" />

</layer-list>
In the layout set the selector file as progressDrawable:

 <RatingBar
        android:id="@+id/ratingBar2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:progressDrawable="@drawable/custom_ratingbar_selector"
        android:numStars="8"
        android:stepSize="0.2"
        android:rating="3.0" />

And that's all we need.

siddhesh
  • 563
  • 1
  • 9
  • 15
0

If it was the same case for you just use:

<androidx.appcompat.widget.AppCompatRatingBar
   ...
   android:secondaryProgressTint="YOUR_COLOR_HERE"/>

Before: enter image description here

After: enter image description here

cigien
  • 57,834
  • 11
  • 73
  • 112
Yasser AKBBACH
  • 539
  • 5
  • 7