Skip to content

Instantly share code, notes, and snippets.

@Firsto
Forked from nisrulz/grayscale_imageview.java
Created November 6, 2017 12:03
Show Gist options
  • Save Firsto/ff9c444ac84e1118e7a54d05d217c973 to your computer and use it in GitHub Desktop.
Save Firsto/ff9c444ac84e1118e7a54d05d217c973 to your computer and use it in GitHub Desktop.
Apply grayscale filter to ImageView in android
ImageView imgview = (ImageView)findViewById(R.id.imageView_grayscale);
imgview.setImageBitmap(bitmap);
// Apply grayscale filter
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imgview.setColorFilter(filter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment