How can I set the star color of the ratingbar?

后端 未结 10 1662
夕颜
夕颜 2021-02-12 19:54

How can I set the star color of the ratingbar? I want yellow stars.

10条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-12 20:38

    It's a little complicated at the mentioned blog, I've used a similar but simplier way. You do need 3 star images (red_star_full.png, red_star_half.png and red_star_empty.png) and one xml, that's all.

    Put these 3 images at res/drawable.

    Put there the following ratingbar_red.xml:

    
    
        
        
        
    
    

    and, finally, tell your ratingbar definition to use this, i.e.

    
    

    That's it.

提交回复
热议问题