I have simple RatingBar
in my app. and i set numStarts="5"
but it show more then 5 star. when i set android:layout_width="match_parent"
I tried to several tutorials but also did't work, as per doc numStarts
for show number of starts but in my case it did't work. i go through doc and several tutorials but did't get any solution.
but i want to only 5 stars in rating bar.
my rating bar is given below.
<RatingBar
style="@style/customRatingBar"
android:id="@+id/course_rating_bar"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:numStars="5"
android:isIndicator="false"
android:stepSize="1.0"/>
This is my custom style
<style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/ratingstars</item>
<item name="android:minHeight">22dip</item>
<item name="android:maxHeight">22dip</item>
</style>
......
<?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/star_empty" />
<item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/star_empty" />
<item android:id="@+android:id/progress"
android:drawable="@drawable/star" />
</layer-list>
You have to set android:layout_width="wrap_content" rather than "match_parent". Then you will get the 5 stars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With