Adding a color filter to a Drawable changes all Buttons using the same Drawable

前端 未结 1 1353
天涯浪人
天涯浪人 2020-11-29 05:49

I have a screen where multiple Buttons use the same background Drawable. I have reusable code I use in various projects to add an OnTouch listener that adds a gray color fil

相关标签:
1条回答
  • 2020-11-29 06:25

    Example that should work for you:

    Drawable buttonBackground = context.getResources().getDrawable(R.drawable.bg);
    buttonBackground = buttonBackground.mutate();
    
    //Set your filter here
    
    0 讨论(0)
提交回复
热议问题