2

I have a problem with a custom rating bar. I have followed the instructions of this post

to create my custom rating bar and the mechanic works but I have a glitch on the end of my bar : [here is a picture]

[2].

The background and the progressDrawable do not seem to fit right. I really don't have a clue where the problem could come from. I thought I had the beginning of an answer in this post but since I didn't use a secondary progressDrawable it didn't help me.

EDIT :

As asked here are the XML files I use. Nothing is done programmatically :

values/style.xml

<style name="UserRatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/user_rating_stars</item>
</style>

drawable/user_rating_stars.xml :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
        android:drawable="@drawable/user_rating_bar_empty"/>
    <item android:id="@android:id/progress"
        android:drawable="@drawable/user_rating_bar_full"/>
</layer-list>

drawable/user_rating_bar_empty :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/star_normal" android:state_pressed="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_normal" android:state_focused="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_normal" android:state_selected="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_normal"/>
</selector>

drawable/user_rating_bar_full :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/star_active" android:state_pressed="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_active" android:state_focused="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_active" android:state_selected="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/star_active"/>
</selector>

Thanks in advance for the help.

Community
  • 1
  • 1
user3476114
  • 634
  • 1
  • 7
  • 17

0 Answers0