According to multiple sources this code should work on an ImageView. An ImageButton is a child class of an ImageView, so this should not be a factor. Just in case, I have tried changing the view to an ImageView. Either way, there is no effect and the image remains in full color.
ImageButton imageButton = findViewById(R.id.imageButton);
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageButton.setColorFilter(filter);
I found the problem: my view did not have an src, only a background, which is to say, it had:
instead of:
These are interchangeable for many purposes, but not for this. When my attempts were not working, the filter was being applied to the non-existent src, which is why nothing happened.