Example usage for android.support.v4.graphics.drawable DrawableCompat setTint

List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable DrawableCompat setTint.

Prototype

public static void setTint(Drawable drawable, int i) 

Source Link

Usage

From source file:Main.java

/**
 * Tints a drawable. Also tints the original resource, use {@link #mutateAndTintDrawable} to not touch the
 * source resource.//from  www  .  j  a v  a  2s.  c  om
 *
 * @param drawable
 *         the drawable to tint
 * @param color
 *         the color to use
 */
public static void tintDrawable(Drawable drawable, int color) {
    DrawableCompat.setTint(drawable, color);
}

From source file:com.bryan.lib.util.TintDrawable.java

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

From source file:org.mozilla.focus.utils.DrawableUtils.java

public static Drawable loadAndTintDrawable(@NonNull Context context, @DrawableRes int resourceId,
        @ColorInt int color) {
    final Drawable drawable = context.getResources().getDrawable(resourceId, context.getTheme());
    final Drawable wrapped = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTint(wrapped, color);
    return wrapped;
}

From source file:org.mozilla.gecko.util.DrawableUtil.java

public static Drawable tintDrawable(@NonNull final Context context, @DrawableRes final int drawableID,
        @ColorRes final int colorID) {
    final Drawable icon = DrawableCompat.wrap(ContextCompat.getDrawable(context, drawableID).mutate());
    DrawableCompat.setTint(icon, ColorUtils.getColor(context, colorID));
    return icon;/*from  w w  w. jav  a  2 s  .  co m*/
}

From source file:com.duy.pascal.ui.common.utils.DrawableUtils.java

public static Drawable tintDrawable(Drawable d, @ColorInt int color) {
    Drawable wd = DrawableCompat.wrap(d);
    DrawableCompat.setTint(wd, color);
    return wd;
}

From source file:com.vinidsl.googleioextended.helper.TintHelper.java

public static Drawable tint(Drawable drawable, int colorResource) {
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(drawable, colorResource);
    DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
    return drawable;
}

From source file:com.triangleleft.flashcards.ui.common.DrawableUtils.java

public static Drawable getTintedDrawable(Context context, @DrawableRes int drawableResId,
        @ColorRes int colorResId) {
    Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, drawableResId));
    DrawableCompat.setTint(drawable, ContextCompat.getColor(context, colorResId));
    return drawable;
}

From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.ViewCustomSetters.java

@BindingAdapter("backgroundTint")
public static void setBackgroundTint(final View view, int tint) {

    if (view.getBackground() == null) {
        return;//from w  w  w  . j  av a 2  s .c  o  m
    }

    Drawable wrapped = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTint(wrapped, tint);
    ViewCompat.setBackground(view, wrapped);
}

From source file:com.tafayor.selfcamerashot.utils.Util.java

public static Drawable tint(Drawable icon, int color) {

    Drawable tintedIcon = DrawableCompat.wrap(icon);
    DrawableCompat.setTint(tintedIcon, color);

    return tintedIcon;
}

From source file:com.github.chenxiaolong.dualbootpatcher.MenuUtils.java

public static void tintMenuItemIcon(MenuItem item, int color) {
    Drawable drawable = item.getIcon();//w w w. j av  a 2  s . com
    if (drawable != null) {
        Drawable wrapped = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(wrapped, color);
    }
}