更改Activity亮度

有些需求需进入到页面后更改Activity的亮度,退出页面后恢复到之前的亮度。通过更改WindowManager.LayoutParams的screenBrightness可以达到这个效果。screenBrightness的默认取值为-1。screenBrightness的有效取值范围为0-1,当其值小于0时,即使用默认屏幕亮度。

1 WindowManager.LayoutParams wl = getWindow().getAttributes();
2 wl.screenBrightness = 0.5f;
3 getWindow().setAttributes(wl);
原文地址:https://www.cnblogs.com/pillowzhou/p/5048083.html