Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the star images of the RatingBar?

With Android SDK 1.1 r1, is there any way to change the RatingBar widget class's star image with my own? Is this possible at all? If so, then how?

Thanks.

like image 362
Chang Chung Avatar asked Mar 03 '09 18:03

Chang Chung


People also ask

How do I change the rating bar on my Android?

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.

What is rating bar in Android?

android.widget.RatingBar. 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.


1 Answers

Not sure about 1.1, but with 1.6 and later you can just extend Widget.RatingBar style and override the properties that are responsible for star drawables (in values/styles.xml):

 <style name="myRatingBar" parent="@android:style/Widget.RatingBar">         <item name="android:progressDrawable">@drawable/my_ratingbar_full</item>         <item name="android:indeterminateDrawable">@drawable/my_ratingbar_full</item>  </style> 

There's no need to subclass RatingBar, just pass this style to it with the 'style' attribute:

<RatingBar style="@style/myRatingBar" ... />  

Download android sources and look at the ratingbar_full.xml in the core drawable folder to see what to put into my_ratingbar_full.

You can find a fuller version of this here: How to create Custom Ratings bar in Android

like image 98
kozyr Avatar answered Nov 04 '22 01:11

kozyr