Reputation: 617
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" />
Upvotes: 4
Views: 3930
Reputation: 2596
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"
Upvotes: 2