Search code examples
androidandroid-layoutratingbar

RatingBar with small white stars


The following is the xml for my rating bar.

<RatingBar
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                style="?android:attr/ratingBarStyleSmall"
                android:numStars="5"
                android:isIndicator="true"
                android:stepSize="0.5"
                android:rating="4.5"/>

I am happy with its size but I would like to stars to be white on grey (white for filled and grey for empty).

I am looking at this tutorial (http://www.materialdoc.com/rating-bar/) but I am not sure how to adapt the style to suit the small appearance.


Solution

  • you can use progressTint for this purpose

      <RatingBar
                            android:id="@+id/vendorRatingBarValue"
                            style="?android:attr/ratingBarStyleSmall"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_alignRight="@+id/reviewerName"
                            android:clickable="false"
                            android:gravity="left|center"
                            android:isIndicator="true"
                            android:numStars="5"
                            android:progressTint="@color/white"
    
                            android:transformPivotX="0dp"
    
                            />