Search code examples
androidxmlratingbar

Android: Ratingbar stepsize below 0.5


I have added a RatingBar to my code and it works well except one thing. I am trying to set a step size to 0.1 but it still reacts according to the default 0.5 step size. I can easily set a step size higher than 0.5 and it will react as intended but not lower.

I can't figure out why? Only thing I can think of is that the RatingBar's step size is capped at 0.5? Which would make no sense for a RatingBar to minimum draw half stars?

<android.support.v7.widget.AppCompatRatingBar
    android:theme="@style/RatingBar"
    android:stepSize="0.1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/ratingbar"
    android:numStars="5"
    android:rating="0.1"
    style="?android:attr/ratingBarStyleSmall"
    android:layout_below="@+id/title"
    android:layout_centerHorizontal="true" />

The above code will show half a star. But according to my knowledge, it should be drawing a tenth of a star.

P.S I have tried to implement it programmatically but still the same.


Solution

  • I fixed this by setting the secondaryProgressTint to #00000000 which is transparent.

    secondaryProgressTint fills out the remainder of begun stars. The color per default is apparently set to the same color as your primary progressTint and therefore causes alot of confusion if you are not aware.

    <android.support.v7.widget.AppCompatRatingBar
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:id="@+id/ratingbar"
               style="?android:attr/ratingBarStyleSmall"
               android:isIndicator="true"
               android:progressTint="@color/Red"
               android:secondaryProgressTint="#00000000"
               android:numStars="5"
               android:rating="3.3"
               android:stepSize="0.1"
               android:layout_below="@+id/title"
               android:layout_centerHorizontal="true"
                />