4

I have to display rating bar with my custom size. But in the case that rating bar with my custom size, the stars disappear in my layout. Can I manage the size of padding and margin the rating bar?

 <RatingBar
                    android:focusable="false"
                    android:id="@+id/rating_order"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:numStars="5"
                    android:stepSize="1.0"
                    android:scaleX="0.3"
                    android:scaleY="0.3" />
KyawLinnThant
  • 617
  • 1
  • 9
  • 20
  • 2
    Possible duplicate of [How to make a smaller RatingBar?](https://stackoverflow.com/questions/2874537/how-to-make-a-smaller-ratingbar) – Manohar Dec 05 '17 at 10:26
  • also see [How can I decrease the size of Ratingbar?](https://stackoverflow.com/questions/6153587/how-can-i-decrease-the-size-of-ratingbar) – Manohar Dec 05 '17 at 10:27
  • It's not exactely the same because he do it with his custom icons and he don't want just to decrease the size – motis10 Dec 05 '17 at 10:28
  • @motis10 in the above link there is an answer for that too – Manohar Dec 05 '17 at 10:41

1 Answers1

2

You can try to set the parameters from styles:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="CustomRatingBar" parent="@android:style/Widget.RatingBar" >
 <item name="android:numStars">5</item>
 <item name="android:stepSize">1.0</item>
 <item name="android:layout_width">wrap_content</item>
 <item name="android:layout_height">wrap_content</item>
 <item name="android:paddingBottom">44dp</item>
 <item name="android:layout_marginLeft">4dp</item>
 <item name="android:layout_marginTop">4dp</item>
  </style>
<resources />

And then in your RatingBar add a style:

style="@style/CustomRatingBar"
motis10
  • 2,484
  • 1
  • 22
  • 46
  • Thank you. You gave me the way to find my hopeful answer. I just change the style parent to @android:style/Widget.Material.RatingBar.Small . That makes my problem. Thank you so much sir. – KyawLinnThant Dec 05 '17 at 10:35
  • DO you know how i can programatically set the size of each star or a specific star, say the 3rd one from 5 stars? – Jono Jul 17 '20 at 13:41