androidrating-system

How can I decrease the size of Ratingbar?


In my activity I have some Rating bars. But the size of this bar is so big! How can I make it smaller?

Edit

Thanks to Gabriel Negut, I did it with the following style:

<RatingBar
style = "?android:attr/ratingBarStyleSmall"
android:numStars = "5"
android:rating   = "4" />

Now, the size is reduced but number of stars and rating do not take effect!!! Why? I have 7 stars that 6 of them is selected.


Solution

  • The original link I posted is now broken (there's a good reason why posting links only is not the best way to go). You have to style the RatingBar with either ratingBarStyleSmall or a custom style inheriting from Widget.Material.RatingBar.Small (assuming you're using Material Design in your app).

    Option 1:

    <RatingBar
        android:id="@+id/ratingBar"
        style="?android:attr/ratingBarStyleSmall"
        ... />
    

    Option 2:

    // styles.xml
    <style name="customRatingBar"   
        parent="android:style/Widget.Material.RatingBar.Small">
        ... // Additional customizations
    </style>
    
    // layout.xml
    <RatingBar
        android:id="@+id/ratingBar"
        style="@style/customRatingBar"
        ... />