public static void setViewSaturation(View root, float sat) {
if (root != null) {
if (!(sat < 0.0F) && !(sat > 1.0F)) {
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(sat);
paint.setColorFilter(new ColorMatrixColorFilter(cm));
root.setLayerType(View.LAYER_TYPE_HARDWARE, paint);
}
}
}
网友评论