How to add button tint programmatically

前端 未结 15 971
时光取名叫无心
时光取名叫无心 2020-11-30 23:38

In the new AppCompat library, we can tint the button this way:

15条回答
  •  不知归路
    2020-12-01 00:36

    You can use DrawableCompat e.g.

    public static Drawable setTint(Drawable drawable, int color) {
        final Drawable newDrawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(newDrawable, color);
        return newDrawable;
    }
    

提交回复
热议问题