37

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,777
  • 5
  • 18
  • 30

3 Answers3

58

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
  • 44,549
  • 13
  • 77
  • 93
  • 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
58

It can be set in the xml too, with

android:stepSize="1"
Daniel Zolnai
  • 16,487
  • 7
  • 59
  • 71
ElYeante
  • 1,745
  • 21
  • 22
18

Try to set the Step size like this

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