Home keyboard_arrow_right Questions keyboard_arrow_right #Views
RatingBar not showing correct stars count
question
0
Vasil Tabakov
Oct. 28, 2018
asked 11 months, 3 weeks ago
viewed 248 times

In a fragment the rating of a RatingBar is set to 5 and the RatingBar is set to show 5 stars. Upon clicking on some button another fragment is presented. After hitting the 'back' key the user returns to the previous fragment (scrolling etc is preserved) but the rating bar is showing only 1 star.


A probably important detail is that (altho it might not be the best thing to do) that in onCreateView the View is saved in a class field (e.g. mView) and returned if it's not null, so no new inflating etc is needed.


However even in this case and after explicitly setting setNumStars(5) the RatingBar is showing 1 star.


Here's the XML of the RatingBar:

<RatingBar
    android:id="@+id/ratingBar"
    android:isIndicator="true"
    android:numStars="5"
    android:stepSize="0.1"
    android:layout_width="wrap_content"
    android:layout_marginBottom="10dp"
    style="?android:attr/ratingBarStyleSmall"
    android:layout_gravity="center_horizontal"
    android:layout_height="wrap_content" />


If debugged the mProgress of the RatingBar is indicated to be 50 and all other values seem correct, but on the screen it's still just showing 1 star.

0 Answers
No replies yet
Any help here will be much appreciated.

sign in Sign in to add your reply or comment.

delete_forever
Careful now...
Doing this you will loose this information and the action cannot be undone.
This action cannot be undone.
cancel