If you do not want Default RatingBar implementation then you can customize it by creating your own layouts and styles for it.
You need to get 3-star images to be added to your drawable folder.
1. A Empty (off) star image.
2. A Half Filled Star image.
3. A Fully Filled Star image.
Now create a custom XML for RatingBar in Drawable folder,
<?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_blank"/>
<item
android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/star_blank"/>
<item
android:id="@+android:id/progress"
android:drawable="@drawable/star_filled"/>
</layer-list>
start_blank.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/star_off"
android:state_pressed="true"
android:state_window_focused="true"/>
<item android:drawable="@drawable/star_off"
android:state_focused="true"
android:state_window_focused="true"/>
<item android:drawable="@drawable/star_off"
android:state_selected="true"
android:state_window_focused="true"/>
<item android:drawable="@drawable/star_off"/>
</selector>
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!