Home » Android » Decrease the size of Rating Bar in Android 2.1

Decrease the size of Rating Bar in Android 2.1

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am currently working on a Mobile App project for Ford company, and I am a newbie in Java Android.

I am just wondering, is there any way to decrease the size of rating bar in Android 2.1?

I want to preserve more spaces for other buttons and edittexts.

Thank you in advance for you help

How to&Answers:

You could try setting style="?android:attr/ratingBarStyleSmall" but the documentation states:

The smaller RatingBar style ( ratingBarStyleSmall) and the larger indicator-only style (ratingBarStyleIndicator) do not support user interaction and should only be used as indicators

Answer:

Rating Bar Style can be set. As the previous answer says, documentation says ratingBarStyleSmall is indicator-only style. But I found that I could set it as not an indicator using:-

android:isIndicator="false"

Answer:

You can change the size of stars by changing the four attributes in style.xml, for e.g.:

 <style name="RatingBar_style" parent="@android:style/Widget.RatingBar">
    <item name="android:minHeight">30dp</item>
    <item name="android:maxHeight">30dp</item>
    <item name="android:height">25dp</item>
    <item name="android:width">25dp</item>
 </style>

minHeight and maxHeight act like canvas on which stars are placed
Change the height and width attributes according to your requirement.