Search code examples
androidxmluser-interface

Android rating baar not showing properly


Ratingbar star not showing properly. i don't know what i am doing wrong with it. when i used custom style then a single star is showing only and its length is equal to 5star.

<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-15dp"
android:stepSize="1"
android:numStars="5"
style="@style/customRatingBar" />

Style is:

<style name="customRatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/manual_ratingbar</item>
    <item name="android:minHeight">32dip</item>
    <item name="android:maxHeight">32dip</item>
</style>

manual_ratingbar file:

<?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_unselect" />
    <item android:id="@android:id/progress" android:drawable="@drawable/ic_star_select" />
</layer-list>

it looks like: enter image description here

and when i changed the Ratingbar style to

style="?attr/ratingBarStyleIndicator"

then there is extra star visible in background. enter image description here what should i do?


Solution

  • @chandan you can resolve this issue by adding this on RatingBar Layout android:indeterminate="false"