简体   繁体   中英

Rating bar with custom size

I have to display rating bar with my custom size. But in the case that rating bar with my custom size, the stars disappear in my layout. Can I manage the size of padding and margin the rating bar?

 <RatingBar
                    android:focusable="false"
                    android:id="@+id/rating_order"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:numStars="5"
                    android:stepSize="1.0"
                    android:scaleX="0.3"
                    android:scaleY="0.3" />

You can try to set the parameters from styles:

<?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:stepSize">1.0</item>
 <item name="android:layout_width">wrap_content</item>
 <item name="android:layout_height">wrap_content</item>
 <item name="android:paddingBottom">44dp</item>
 <item name="android:layout_marginLeft">4dp</item>
 <item name="android:layout_marginTop">4dp</item>
  </style>
<resources />

And then in your RatingBar add a style:

style="@style/CustomRatingBar"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM