4

I created custom rating bar. I set default small rating bar in app. But the stars gaps are none. How to make gaps in each stars? I can give my xml file code given below:

customratingbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@android:id/background"
        android:drawable="@drawable/ic_star_normal"

        ></item>

    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/ic_star_selected"></item>

    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/ic_star_selected"></item>

</layer-list>

Styles.xml:

<style name="CustomRating" parent="android:style/Widget.Material.RatingBar.Small">

        <item name="android:progressDrawable">@drawable/custom_ratingbar</item>
        <item name="android:paddingBottom">4dip</item>
        <item name="android:layout_marginLeft">4dip</item>
        <item name="android:layout_marginRight">5dip</item>
        <item name="android:layout_marginTop">4dip</item>

    </style>

what mistake I make it? I don't know. How can I solve this? I beginner I don't know that.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96

2 Answers2

6

You can contact your UI/UX Designer or You can re-create slice images using Android Asset Studio Tool

Upload Star Image at Android Asset Studio and set padding what you want Ex. like 8dp

Kishore Jethava
  • 6,666
  • 5
  • 35
  • 51
0

First thing you check your image size like height and width.

Then you just add in your styles.xml --you can vary height size

<style name="CustomRating" parent="android:style/Widget.Material.RatingBar.Small">
   <item name="android:progressDrawable">@drawable/custom_rating</item>
        <item name="android:minHeight">40dp</item>
        <item name="android:maxHeight">40dp</item>
</style>

And finally you add it into your layout.

 <RatingBar
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:numStars="5"
  android:fitsSystemWindows="true"
  style="@style/CustomRating"
  android:id="@+id/rating_bar" />
  • i use image size 14*14 size of stars.can i reduce star image size below 14 –  Feb 14 '17 at 04:57