How can I set the star color of the ratingbar?

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

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

10条回答
  •  自闭症患者
    2021-02-12 20:34

    try this one

    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
    stars.getDrawable(2).setColorFilter(Color.YELLOW,PorterDuff.Mode.SRC_ATOP);
    

提交回复
热议问题