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.
It features:
- Fully working
android:layout_width
: it can be set to wrap_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.
Here is a preview of it.
In your case, you would just have to do:
ratingbar.setStarsSeparation(20, Dimension.DP);
or, for example, in pixels:
ratingbar.setStarsSeparation(100, Dimension.PX);
You can find it either in jcenter
or in Maven Central
. So in your build.gradle
file just add to your dependencies:
compile 'com.iarcuschin:simpleratingbar:0.1.+'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…