Code example for ColorMatrix

Methods: set

0
 */ 
public class BaseFilter { 
 
    public Drawable applyFilter(Drawable drawable) {
 
        ColorMatrix colorMatrix = new ColorMatrix();
 
        colorMatrix.set(getTransformationMatrix());
 
        drawable.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
 
        return drawable;
    } 
 
    public float[] getTransformationMatrix() { 
        return new float[]{1, 0, 0, 0, 0, 
                0, 1, 0, 0, 0, 
                0, 0, 1, 0, 0, 
                0, 0, 0, 1, 0}; 
    } 
}