Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smaller Custom RatingBar: Material Design

I am building an app which uses a non-clickable (indicator) ratingbar. Now, when the ratingbar IS clickable, it has two different modes. When clicked the icons turn red (red is the accentColor in my styles). When not clicked, the stars are an ugly gray with a black outline. When a rating bar is set to unclickable (indicator), the stars are permanently black-and-gray.

Additionally, I would like to make the stars smaller. Can I do both of the above things without defining custom drawables? If I must define custom drawables, how can I access the preexisting "clicked star" drawable, so that I do not need to create my own?

Thanks

like image 502
TeslaK20 Avatar asked Nov 09 '22 16:11

TeslaK20


1 Answers

                <RatingBar
                    style="@style/RatingBar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:numStars="5"
                    android:rating="3.5"
                    android:stepSize="0.5" />

and add this in your styles xml file

<style name="RatingBar"   
parent="android:style/Widget.Material.RatingBar.Small">
<item name="colorControlNormal">@color/primary_light</item>
<item name="colorControlActivated">@color/primary_dark</item>
</style>

visit my Blog Post and see working example. This way you dont need to customise ratingBar.

like image 90
Developine Avatar answered Nov 14 '22 23:11

Developine