Can't change the size of custom RatingBar

心已入冬 提交于 2019-12-06 09:05:37

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

Just add below lines to your ratingBar in xml layout

    android:scaleX="0.5"
    android:scaleY="0.5"
Manoj Janaka

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 refer to the following example:

<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 https://en.proft.me/2017/06/18/decorating-ratingbar-android/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!