Android 界面一键变灰/黑白
Activity中加入以下代码(kotlin)
val paint = Paint() val colorMatrix = ColorMatrix() colorMatrix.setSaturation(0f) paint.colorFilter = ColorMatrixColorFilter(colorMatrix) window.decorView.setLayerType(View.LAYER_TYPE_HARDWARE, paint)
Activity中加入以下代码(kotlin)
val paint = Paint() val colorMatrix = ColorMatrix() colorMatrix.setSaturation(0f) paint.colorFilter = ColorMatrixColorFilter(colorMatrix) window.decorView.setLayerType(View.LAYER_TYPE_HARDWARE, paint)