将页面置灰(默哀模式)

2022-12-01  本文已影响0人  小相柳
 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);
            }
        }
    }
上一篇下一篇

猜你喜欢

热点阅读