I want to use RatingBar
in the layout i am using. it should contain maximum 5 stars. the problem now is, when i use the below posted code, I get a RatingBar
with
more than 5 stars
i would like to know how should i modify the below costed view so I can use exactly 5 start
code:
<RatingBar
android:id="@+id/cardViewRatingBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:numStars="5"
android:rating="4"
android:stepSize=".5"
style="?android:attr/ratingBarStyleSmall"/>
I believe your problem is likely down to the layout width. I don't think ratingBar can be successfully set to anything other than "wrap_content" otherwise you end up with the problem that you have described.
Try this:
<RatingBar
android:id="@+id/cardViewRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="4"
android:stepSize=".5"
style="?android:attr/ratingBarStyleSmall"/>
As a result you may have to do a little work with the parent layout to set it how you want in the activity, or you can try different style settings for the bar.