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.
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"
... />
This was my solution after a lot of struggling to reduce the rating bar in small size without even ugly padding
<RatingBar
android:id="@+id/listitemrating"
style="@android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX=".5"
android:scaleY=".5"
android:transformPivotX="0dp"
android:transformPivotY="0dp"
android:isIndicator="true"
android:max="5" />