Example usage for android.graphics.drawable LayerDrawable setColorFilter

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

Introduction

In this page you can find the example usage for android.graphics.drawable LayerDrawable 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:net.xpece.android.colorpicker.ColorStateDrawable.java

public static Drawable create(Drawable[] layers, int color, int pressed) {
    if (Build.VERSION.SDK_INT >= 21) {
        LayerDrawable ld = new LayerDrawable(layers);
        ld.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        RippleDrawable rd = new RippleDrawable(ColorStateList.valueOf(pressed), ld, null);
        return rd;
    } else {/*from  w w  w . j av a2  s .  c  o  m*/
        return new ColorStateDrawable(layers, color, pressed);
    }
}