How to make a smaller RatingBar?

09 Feb

How to glue the code given here 

Step-1. You need your own rating stars in res/drawable …

A full star

Half star

Empty star

Step-2 In res/drawable you need ratingstars.xml as follow …

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
    <item android:id="@+android:id/background"
          android:drawable="@drawable/star_empty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/star_empty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/star" />

Step-3 In res/values you need styles.xml as follow …

<?xml version="1.0" encoding="utf-8"?>
    <style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
        <item name="android:progressDrawable">@drawable/ratingstars</item>
        <item name="android:minHeight">22dip</item>
        <item name="android:maxHeight">22dip</item>

Step-4 In your layout …


Referenced by:


Posted by on February 9, 2012 in Android


2 responses to “How to make a smaller RatingBar?

  1. pedrera_j

    May 16, 2012 at 9:21 PM

    Thanks, It is a very useful post. I have found a problem when you use the style from the code with:

    RatingBar ratingBar = new RatingBar(this, null,;

    The ratingBar doesn’t appear
    I need this, because the ratingbar alongs to a item list. Is there some alternative way?

  2. pedrera_j

    May 16, 2012 at 9:21 PM

    Sorry, I wanted to say “the ratingbar belongs to a item list”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: