android view置灰(哀悼日)

置灰前


置灰前.jpg

置灰后


置灰后.jpg

给Activity的顶层View设置置灰,实现全局置灰效果。获取界面的根View:

        View view  = getActivity(). getWindow(). getDecorView();
        Paint paint = new  Paint();
        ColorMatrix cm = new  ColorMatrix();
        cm.setSaturation(0);
        paint.setColorFilter(new ColorMatrixColorFilter(cm));
        view. setLayerType(View.LAYER_TYPE_HARDWARE, paint);

你可能感兴趣的:(android view置灰(哀悼日))