评分栏仅显示半颗星而不是全星
我正在开发一个应用程序,需要动态创建一个 4 星的不可编辑的小样式评级栏。
当我调用 setRating(4)
时,它显示 4 颗星,没有任何问题。 但是当我调用 setRating(3)
时,它显示 3 颗半星。 setRating(2)
正确显示 2 颗星, 但 setating(1)
显示 1 颗半星。
当我在另一个活动中使用普通评级栏时,它工作正常,但是当我使用小型不可编辑评级栏时,它无法正常工作。
这与 api 级别或小样式不可编辑评级栏有什么关系吗?
初始化是这样完成的:
RatingBar ioRatingBar = new RatingBar(this,null,android.R.attr.ratingBarStyleSmall);
ioRatingBar.setNumStars(4);
ioRatingBar.setRating(3);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置步长
RatingBar
像这样,并尝试定义 最大评级为:
You need to set the step size of the
RatingBar
like thisand also try to define the max rating as:
如果存在
padding
,则删除。我建议用margin
替换。If exist
padding
, remove. I suggest replace withmargin
.