35

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.

Frank
  • 2,345
  • 5
  • 15
  • 28

3 Answers3

57

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.

codeMagic
  • 43,753
  • 13
  • 72
  • 91
  • Uhm, the same answer twice... Should I accept both of them? (I am quite a rookie here :S) – Frank Jan 08 '13 at 17:59
  • They were right after each other so we were probably typing at the same time. If one was more helpful than the other at all then I would accept that one. If not, then accept the first one or whichever you want...no big deal as long as you accept one of them :) – codeMagic Jan 08 '13 at 18:01
56

It can be set in the xml too, with

android:stepSize="1"
Daniel Zolnai
  • 14,536
  • 7
  • 52
  • 64
ElYeante
  • 1,580
  • 19
  • 21
18

Try to set the Step size like this

ratingBar.setStepSize(1.0);
Gridtestmail
  • 1,419
  • 9
  • 10