评分星号之间的间隔 [英] Space Between stars of ratingBar
问题描述
我需要在我的ratingBar的星星之间插入一个空格,例如ratingbar很好:
I need insert a space between the stars of my ratingBar, example the ratingbar is well:
但是我因此需要它:
我该怎么做?
推荐答案
我不知道它是否会有用,但是我制作了一个自定义库,该库允许您以编程方式和XML格式更改空间beetwen stars东西): SimpleRatingBar .
I don't know if it will be useful anymore, but I made a custom library which allows you to change space beetwen stars programatically and in XML (among other stuff): SimpleRatingBar.
它具有以下特点:
- 完全正常工作的
android:layout_width
:可以将其设置为wrap_content
,match_parent
或非婚生dp. - 任意数量的星星.
- 任意步长.
- 可以完全控制星星大小,也可以设置最大大小.
- 正常状态下的可自定义颜色(边框,星号的填充和背景以及等级栏).
- 处于按下状态的可自定义颜色(边框,星号的填充和背景以及等级栏).
- 可自定义的星际大小分隔.
- 可自定义的星星边框宽度.
- 可自定义的星星转角半径.
- 允许设置OnRatingBarChangeListener
- 可以将星星填充设置为从左到右或从右到左开始(RTL语言支持).
- 集成在视图中的AnimationBuilder可通过动画以编程方式设置评分.
- Fully working
android:layout_width
: it can be set towrap_content
,match_parent
or abritary dp. - Arbitrary number of stars.
- Arbitrary step size.
- Size of stars can be controlled exactly or by setting a maximum size.
- Customizable colors in normal state (border, fill and background of stars and rating bar).
- Customizable colors in pressed state (border, fill and background of stars and rating bar).
- Customizable size separation between stars.
- Customizable border width of stars.
- Customizable stars corner radius.
- Allows to set OnRatingBarChangeListener
- Stars fill can be set to start from left to right or from right to left (RTL language support).
- AnimationBuilder integrated in the view to set rating programatically with animation.
就您而言,您只需要执行以下操作即可:
In your case, you would just have to do:
ratingbar.setStarsSeparation(20, Dimension.DP);
或例如,以像素为单位
ratingbar.setStarsSeparation(100, Dimension.PX);
您可以在 jcenter
或 Maven Central
中找到它.因此,在您的 build.gradle
文件中,只需添加到您的依赖项中即可:
You can find it either in jcenter
or in Maven Central
. So in your build.gradle
file just add to your dependencies:
编译'com.iarcuschin:simpleratingbar:0.1.+'
这篇关于评分星号之间的间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!