Android changing the stars of rating bar with images you like


In this Blog, we will learn on how to change the rating bar content with your own custom images, (images can be any thing like a star with your own colour and background of your choice, or anything that you want to represent the rating with).

Please note that here we will try to change the icon of star with our own, that is one image of ours will represent a unit of rating.

Implementing this is very easy, let’s have a look on how to do it :

  1. Create a new drawable file with layer list as parent tag. (say,my_rating_display)
  2. Add three items in it with ids “@android:id/background” , “@android:id/secondaryProgress”, “@android:id/progress” respectively.
  3. Create a drawable or image that you want to set as background(when rating will be zero). and add it to the item with id background.
  4. Create a drawable or image that you want to set as filled star(when rating will be one). and add it to the item with id progress.
  5. Create a drawable or image that you want to set as half star(when rating will be one). and add it to the item with id progress.
  6. Now set the attribute “progressDrawable” to my_rating_display.

And it is done.



And the code of Rating bar :


. . .
Discuss on Helpdesk

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Howard
    I hope that this is a work in progress as it doesn’t seem to be complete. For instance: what is @drawable/my_rating_display”, where has it come from?
    • anchit (Moderator)
      Thanks for pointing this issue. The blog itself is complete. It was just that i missed the label of the file.
      If you would have read the contents of the article, then you would have easily understood what that file is and where it came from. If still have any doubts, please feel free to revert and i will reply ASAP.
  • hila
    hey, great job!
    but I have a few problems with your example, I followed the steps and only 2 stars are appearing (i used android:numStars=”5″ at ratingBar) on default size (even though i tried changing the size with width and height on item attributes at my_rating_display.xml). what do you suggest to do?
    • anchit (Moderator)
      What is the resolution of your each drawable that you are using?
      Can you share your code so that i can have abetter insight and try to fix that ?
  • css.php
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home