Android 界面一键变灰/黑白

Activity中加入以下代码(kotlin)

val paint = Paint()
val colorMatrix = ColorMatrix()
colorMatrix.setSaturation(0f)
paint.colorFilter = ColorMatrixColorFilter(colorMatrix)
window.decorView.setLayerType(View.LAYER_TYPE_HARDWARE, paint)

  

posted @ 2020-05-20 15:19  心夢無痕  阅读(1975)  评论(0编辑  收藏  举报