Can't change the size of custom RatingBar

Pial Kanti picture Pial Kanti · Feb 5, 2016 · Viewed 9k times · Source

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 CustomRatingBar 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: enter image description here

Drawable files are : custom_ratingbar.xml, custom_ratingbar_empty, custom_ratingbar_filled

In my xml, RatingBar 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?

Answer

Sanjay Kushwah picture Sanjay Kushwah · Mar 4, 2019

Just add below lines to your ratingBar in xml layout

    android:scaleX="0.5"
    android:scaleY="0.5"