Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the custom size of the stars in RatingBar

I have already added a style

<style name="myRatingBar" parent="@android:style/Widget.RatingBar">     <item name="android:minHeight">32dp</item>     <item name="android:maxHeight">32dp</item> </style> 

However instead of scaled stars I'm receiving cropped stars:

enter image description here

Is there a way to change the size of the stars?

like image 750
Marcin S. Avatar asked Sep 12 '12 06:09

Marcin S.


People also ask

How do I customize my rating bar?

Custom Rating Bar in AndroidCopy your images in the drawable folder and remember image size should be according to the size you want. Step 2. Make XML for the rating bar selector in the drawable folder like below. We made two files, one for the fill or highlighted part and one for the empty or un-highlighted part.

How to increase size of rating bar in Android?

You can set it in the XML code for the RatingBar, use scaleX and scaleY to adjust accordingly. "1.0" would be the normal size, and anything in the ". 0" will reduce it, also anything greater than "1.0" will increase it.

How can set rating bar rating in Android?

A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. The user can touch/drag or use arrow keys to set the rating when using the default size RatingBar. The smaller RatingBar style ( R.


2 Answers

Another approach would be scaling the widget:

android:scaleX="0.5" android:scaleY="0.5" 
like image 121
xleon Avatar answered Sep 23 '22 02:09

xleon


Android won't scale a rating bar icons. When you decrease the minHeight and maxHeight android will always crop the icons as shown on the picture. The workaround for it and seems to be the only one solution is to provide your own icons for stars with the desired dimensions and set the minHeight and maxHeight to the size of the icons.

like image 24
Marcin S. Avatar answered Sep 24 '22 02:09

Marcin S.