Search code examples
androidandroid-drawablerippledrawable

Android - Set a Drawable to multiple buttons


Setting a same Drawable to multiple buttons/views as backgrounds (using setBackground(Drawable) has problem with ripple effect, when I click Button A, the ripple effect of Button B would be shown.

Note: I tested mutate() but nothing worked


Solution

  • Try Drawable newDrawable = oldDrawable.getConstantState().newDrawable().mutate();