Android DrawableCompat 着色

80 阅读1分钟

Android DrawableCompat 着色

public static void imgSetRed(ImageView imgView) {
        if (imgView == null) return;
        WeakReference<ImageView> w = new WeakReference<>(imgView);
        Drawable tintIcon = DrawableCompat.wrap(w.get().getDrawable().mutate());
        DrawableCompat.setTint(tintIcon,Color.RED);
        w.get().setImageDrawable(tintIcon);
    }