Home » Android » android – How to allow full values (integers) only in ratingbars?

android – How to allow full values (integers) only in ratingbars?

Posted by: admin April 23, 2020 Leave a comment

Questions:

My client wants a ratingbar in one of the activities, but he doesn’t want it to allow half-stars (aka float) values.
I’ve been google-ing around but found nothing about it. Does anybody know if it is possible to force the ratingbar to not allow half-stars?

Thanks in advance.

How to&Answers:

Should be able to use setStepSize() and use a 1.0 to allow increments of 1 star instead of 0.5 for half stars

Here is the docs on it.

Answer:

It can be set in the xml too, with

android:stepSize="1"

Answer:

Try to set the Step size like this

ratingBar.setStepSize(1.0);