set Color Matrix for ImageView - Android User Interface

Android examples for User Interface:ImageView

Description

set Color Matrix for ImageView

Demo Code


//package com.java2s;

import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;

import android.widget.ImageView;

public class Main {
    public static void setLocked(ImageView v) {
        ColorMatrix matrix = new ColorMatrix();
        matrix.setSaturation(0); //0 means grayscale
        ColorMatrixColorFilter cf = new ColorMatrixColorFilter(matrix);
        v.setColorFilter(cf);/* ww w  .  ja va  2  s  . c  o m*/
        v.setAlpha(128); // 128 = 0.5
    }
}

Related Tutorials