Can't change the size of custom RatingBar


I am trying to make custom RatingBar for my android app in which i can change the default size and color of RatingBar. For this purpose i have written styles for <strong>CustomRatingBar</strong> like this:

<style name="CustomRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/custom_ratingbar</item> <item name="android:minHeight">25dp</item> <item name="android:maxHeight">25dp</item> </style>

But the size is not changed rather it shrinks the rating bar like this: <a href="https://i.stack.imgur.com/tXgkx.jpg" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/tXgkx.jpg" data-original="https://i.stack.imgur.com/tXgkx.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Drawable files are : <a href="http://pastebin.com/ebCLikfz" rel="nofollow">custom_ratingbar.xml</a>, <a href="http://pastebin.com/ZkyZ0UrY" rel="nofollow">custom_ratingbar_empty</a>, <a href="http://pastebin.com/NaYqxiMt" rel="nofollow">custom_ratingbar_filled</a>

In my xml, <strong>RatingBar</strong> looks like below:

<RatingBar android:id="@+id/RatingBar" style="@style/CustomRatingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:isIndicator="true" android:numStars="5" />

How can i change the star size of the rating bar without shrinking it?


Try this ,

custom rating bar style using android’s ratingBar small style.

<?xml version="1.0" encoding="utf-8"?> <resources> <style name="CustomRatingBar" parent="@android:style/Widget.RatingBar" > <item name="android:numStars">5</item> <item name="android:rating">4.5</item> <item name="android:stepSize">0.5</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:paddingBottom">44dip</item> <item name="android:layout_marginLeft">4dip</item> <item name="android:layout_marginTop">4dip</item>

Check <a href="http://android-helper.blogspot.in/2011/06/android-custom-ratingbar-example.html" rel="nofollow">example.</a> for the same.

Other solution is :

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. There 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.


I came across the same issue and even though this question is very old, I hope this will help someone who comes across this kind of scenario.

To increase the size of the stars in the rating bar we need to use android:scaleX and android:scaleY. Please reffer the following excample,

<RatingBar android:id="@+id/ratingBar" android:numStars="5" android:rating="4" android:isIndicator="true" android:scaleX=".5" android:scaleY=".5" android:transformPivotX="0dp" android:transformPivotY="0dp" android:layout_marginBottom="-26dp" android:layout_marginRight="-100dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:theme="@style/FoursquareReviewRating"/>

Also, you can find more details at <a href="https://en.proft.me/2017/06/18/decorating-ratingbar-android/" rel="nofollow">https://en.proft.me/2017/06/18/decorating-ratingbar-android/</a>


  • Background image crashes android
  • How to automatically pop-up keyboard?
  • Float Label hint (TextInputLayout) not works with Android Data Binding
  • EditText ignores the ImeActionLabel
  • Gray line inside cardview :)?
  • Flask not finding files in my package's 'static' directory
  • Getting short path in python
  • get path to groovy source file at runtime
  • Does Apportable support to build library binary (.a/.so)?
  • Yii2: Finding file and getting path in a directory tree
  • How to create CGPath from a SKSpriteNode in SWIFT
  • How to get current document uri in XSLT?
  • List images(01.png) and descriptions(01.txt) from directory
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • How integrated is Collada to OpenGL ES
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • Xcode 4 NSLog Macro link in Xcode 3
  • How to render a blob on a canvas element?
  • Abort upload large uploads after reading headers
  • Play WS (2.2.1): post/put large request
  • How to delay loading a property with linq to sql external mapping?
  • Ajax Loaded meta Tags
  • Nant, Vault & Windows Integrated Authentication
  • HTML download movie download link
  • swift auto completion not working in Xcode6-Beta
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Deserializing XML into class C#
  • htaccess rewriting URLs with multiple forward slashes
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • jquery mobile loadPage not working
  • SVN: Merging two branches together
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?
  • Busy indicator not showing up in wpf window [duplicate]
  • How to Embed XSL into XML