Rating Bar not working properly on small screen

Viewed 163

Default rating bar of android with custom theme not working properly because when we tap on specific star then next star automatically selected and for unselect star we need to tap on star previous 2 from current star that i want to unselect

My XML Code

<RatingBar
                        android:id="@+id/rate_bar"
                        style="@style/StarRatingBarCheckout"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_marginTop="@dimen/margin_5"
                        android:layout_marginBottom="@dimen/margin_5"
                        android:numStars="5" />

Style for rating bar is StarRatingBarCheckout that i have mentioned in style.xml

  <style name="StarRatingBarCheckout" parent="@android:style/Widget.RatingBar">
        <item name="android:progressDrawable">@drawable/star_rating_bar_full_checkout</item>
        <item name="android:minHeight">35dip</item>
        <item name="android:maxHeight">35dip</item>
        <item name="android:stepSize">1</item>
    </style>

star_rating_bar_full_checkout.xml is

<?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_ratingbar_full_empty_checkout"
        />
    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/star_ratingbar_full_empty_checkout"
        />
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/star_ratingbar_full_filled_checkout" />
</layer-list>

Same code working well on large screen

1 Answers

Try to put android:stepSize="1" into ratingBar tag

Related