要对可绘制对象进行灰度化,我会这样做:
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(200);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
drawable.setColorFilter(filter);
正如贾斯汀所说。它工作正常。
我正在使用 svg-android 库。所以我正在尝试:
PictureDrawable pictureDrawable = svg.createPictureDrawable();
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(200);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
pictureDrawable.setColorFilter(filter);
imageView.setImageDrawable(pictureDrawable);
但是什么也没有发生……怎么了?