Example usage for android.graphics.drawable Drawable setColorFilter

List of usage examples for android.graphics.drawable Drawable setColorFilter

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable setColorFilter.

Prototype

public void setColorFilter(@ColorInt int color, @NonNull PorterDuff.Mode mode) 

Source Link

Document

Specify a color and Porter-Duff mode to be the color filter for this drawable.

Usage

From source file:Main.java

public static void overrideMediumButtonColor(int i, Drawable drawable) {
    drawable.setColorFilter(i, android.graphics.PorterDuff.Mode.MULTIPLY);
}

From source file:Main.java

public static void overrideColorWithTransparency(int i, Drawable drawable, int j) {
    drawable.setColorFilter(i, android.graphics.PorterDuff.Mode.MULTIPLY);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        drawable.setAlpha(j);/*from  w  ww .  j  a  v  a 2s .c  om*/
    }
}

From source file:Main.java

/**
 * TODO doc/*from  ww w .ja va  2s  .  c  o  m*/
 *
 * @param sourceBitmap
 * @param color
 * @return
 */
public static Drawable getDrawableSilhouetteWithColor(Drawable sourceBitmap, int color) {
    sourceBitmap.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    return sourceBitmap;
}

From source file:Main.java

/**
 * Method to get a colored Drawable silhouette.
 *
 * @param sourceBitmap The original Bitmap.
 * @param color        Color of the frame.
 * @return The colored Drawable silohuette.
 *///w ww. j a  v  a2s . c om
public static Drawable getSilhouetteWithColor(Drawable sourceBitmap, int color) {
    sourceBitmap.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    return sourceBitmap;
}

From source file:Main.java

public static void overrideImageColor(int i, Drawable drawable) {
    drawable.mutate();/*  ww  w  .j  av a2s . c  o  m*/
    drawable.setColorFilter(i, android.graphics.PorterDuff.Mode.SRC_IN);
}

From source file:Main.java

public static Drawable colorDrawable(Context context, Drawable drawable, int colorId) {
    Drawable result = drawable.mutate();
    result.setColorFilter(context.getResources().getColor(colorId), PorterDuff.Mode.MULTIPLY);
    return result;
}

From source file:Main.java

static void brandGlowEffect(Context context, int brandColor) {
    //glow/*from  w  w  w  . j a  v  a  2  s.  c  o m*/
    int glowDrawableId = context.getResources().getIdentifier("overscroll_glow", "drawable", "android");
    Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
    androidGlow.setColorFilter(brandColor, PorterDuff.Mode.MULTIPLY);
    //edge
    int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable", "android");
    Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
    androidEdge.setColorFilter(brandColor, PorterDuff.Mode.MULTIPLY);
}

From source file:Main.java

public static Drawable getTintedDrawable(int resDrawable, int tintColor, Context context) {
    Drawable d = context.getResources().getDrawable(resDrawable); // ToDo: use non-deprecated method
    d.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
    return d;/*from  w ww  .  ja va  2  s  .c  o m*/
}

From source file:com.fa.mastodon.util.ThemeUtils.java

public static void setDrawableTint(Context context, Drawable drawable, @AttrRes int attribute) {
    drawable.setColorFilter(getColor(context, attribute), PorterDuff.Mode.SRC_IN);
}

From source file:com.keylesspalace.tusky.ThemeUtils.java

static void setDrawableTint(Context context, Drawable drawable, @AttrRes int attribute) {
    drawable.setColorFilter(getColor(context, attribute), PorterDuff.Mode.SRC_IN);
}