How can I decrease the size of Ratingbar?
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" />
If you want to show the rating bar in small size, then just copy and paste this code in your project.
<RatingBar
android:id="@+id/MyRating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/getRating"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.1" />
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"
... />
The below snippet worked for me to resize the ratingBar
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleIndicator"
android:scaleX=".5"
android:rating="3.5"
android:scaleY=".5"
android:transformPivotX="0dp"
android:transformPivotY="0dp"
android:max="5"/>