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

最后都变了- 提交于 2019-12-01 13:40:58

问题


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.


回答1:


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.




回答2:


It can be set in the xml too, with

android:stepSize="1"



回答3:


Try to set the Step size like this

ratingBar.setStepSize(1.0);


来源:https://stackoverflow.com/questions/14218029/how-to-allow-full-values-integers-only-in-ratingbars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!