How to make a smaller RatingBar?

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:

2 thoughts on “How to make a smaller RatingBar?

  1. 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?

Leave a Reply to pedrera_j Cancel 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