FlyingPumba / SimpleRatingBar

Open source project which features a simple yet powerful RatingBar alternative to Android's default
Apache License 2.0
1.03k stars 142 forks source link

Styling SimpleRatingBar #41

Open willemevenwel opened 6 years ago

willemevenwel commented 6 years ago

Hi,

Firstly, thanks for a great library, this is so much better than standard RatingBar.

My question is: is it possible to style this SimpleRatingBar in a style resource file?

And if so could you show an example.

Regards,

Willem

carlosmuvi commented 6 years ago

@willemevenwel You just have to create a new style. Don't add the app: prefix to the attributes.

   <style name="YourRatingBarStyle">
        <item name="srb_numberOfStars">5</item>
        <item name="srb_starBorderWidth">2.5</item>
        <item name="srb_stepSize">0.5</item>
        <item name="srb_isIndicator">true</item>
        <item name="srb_starCornerRadius">5</item>
        <item name="srb_starSize">15dp</item>
        <item name="srb_starsSeparation">@dimen/your_separating</item>
        <item name="srb_borderColor">@color/your_color</item>
        <item name="srb_fillColor">@color/your_color</item>
    </style>

And then, in your layout:

        <com.iarcuschin.simpleratingbar.SimpleRatingBar
            android:id="@+id/rating"
            style="@style/YourRatingBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />