i use this library to show svg image on imageView , i want to show locked and unlocked mode with this imageView, when state is locked show imageView in grayscale color filter. something like this code on css :
-webkit-filter: grayscale(100%);
opacity: 0.5;
how can i do this ? can anybody help me ? thanks
You should be able to make the image greyscale and faded using the following:
public static void setLocked(ImageView v)
{
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0); //0 means grayscale
ColorMatrixColorFilter cf = new ColorMatrixColorFilter(matrix);
v.setColorFilter(cf);
v.setImageAlpha(128); // 128 = 0.5
}
And reset it using:
public static void setUnlocked(ImageView v)
{
v.setColorFilter(null);
v.setImageAlpha(255);
}