Adding Margin / Padding to RatingBar
I have an image of a rating bar:
Now, I would like to know how to add a field / padding to each item in the evaluation bar?
styles.xml
<resources>
<style name="starRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@layout/starratingbar_full</item>
<item name="android:minHeight">19dp</item>
<item name="android:maxHeight">19dp</item>
</style>
</resources>
starratingbar_full.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="20dp"
android:layout_width="30dp">
<item android:id="@+android:id/background"
android:drawable="@drawable/starunselected"
/>
<item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/starunselected" />
<item android:id="@+android:id/progress"
android:drawable="@drawable/starselected" />
</layer-list>
activity.xml
<RatingBar
style="@style/starRatingBar"
android:numStars="5"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/ratingBar"
android:layout_marginLeft="130dp"
android:layout_marginTop="88dp"
android:stepSize="1"/>
Can anyone please help?
+3
Matthew du plessis
source
to share
2 answers
Using any photoshop or any editor just you could add white space to the left and right of your PNGs.
+3
Raja rajan
source
to share
If you are using Drawable for stars. Make sure your drawable has left padding as per your requirement.
Otherwise the code doesn't work . I faced the same problem a few days ago. I went through the left filled image. Hope it works.
+2
user3528635
source
to share