Modifying the color of an android drawable

后端 未结 6 1065
一生所求
一生所求 2020-11-30 17:30

I would like to be able to use the same drawable to represent both:

\"Blue and

6条回答
  •  孤独总比滥情好
    2020-11-30 18:04

    This is what i did after looking into documentation

    public PorterDuffColorFilter getDrawableFilter(){
            return new PorterDuffColorFilter(ContextCompat.getColor(this, R.color.color_black), PorterDuff.Mode.SRC_ATOP);
        }
    

    and called it

    yourdrawable.setColorFilter(getDrawableFilter());
    

提交回复
热议问题