Space Between stars of ratingBar

前端 未结 5 607
自闭症患者
自闭症患者 2020-12-15 02:43

I need insert a space between the stars of my ratingBar, example the ratingbar is well:

\"enter

相关标签:
5条回答
  • 2020-12-15 03:25

    Just use the custom icon for it and do use the style , i mean Photoshop it as you want it to look and replace with the system rating style icon.

    0 讨论(0)
  • 2020-12-15 03:29

    You have a next property.

    android:progressDrawable = "@drawable/rating_stars"
    android:indeterminateDrawable = "@drawable/rating_stars"
    

    @drawable/rating_stars :

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@+android:id/background"
              android:drawable="@drawable/star_empty" />
        <item android:id="@+android:id/secondaryProgress"
              android:drawable="@drawable/star_empty" />
        <item android:id="@+android:id/progress"
              android:drawable="@drawable/star" />
    </layer-list>
    

    star_empty and star are the images which are in your drawable directory. So, you can change star and star_empty in a graphic editor and add a spassing if you need.

    0 讨论(0)
  • 2020-12-15 03:41

    I think you'd have to grab a copy of the systems star png file and manually add the padding that you want to it with a photoshop / gimp / some other editor.

    0 讨论(0)
  • 2020-12-15 03:45

    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.+'

    0 讨论(0)
  • 2020-12-15 03:48

    I agree to Tim i applied same logic and it worked. Here in my project i am using my own star images for the star ratin I made star images having extra space (padding) on the right side that resulted in space between the stars

    0 讨论(0)
提交回复
热议问题