I'm working on an app that needs to create a non editable small style rating bar with 4 stars dynamically.
When I call setRating(4)
it shows 4 stars without any problem.
But when I call setRating(3)
it shows 3 and half stars.
setRating(2)
shows 2 stars correctly,
but setrating(1)
shows 1 and half stars.
When I use a normal rating bar in another activity it works fine, but when I use the small style non editable rating bar it doesn't work properly.
Does this have anything to do with the api level or small style non editable rating bar?
Initialization is done like this:
RatingBar ioRatingBar = new RatingBar(this,null,android.R.attr.ratingBarStyleSmall);
ioRatingBar.setNumStars(4);
ioRatingBar.setRating(3);
You need to set the step size of the RatingBar
like this
ratingBar.setStepSize(1.0);
and also try to define the max rating as:
ratingBar.setMax(4);