只针对当前应用窗口,不影响系统屏幕亮度的设置
原文解释
This can be used to override the user's preferred brightness of
the screen. A value of less than 0, the default, means to use the
preferred screen brightness. 0 to 1 adjusts the brightness from
dark to full bright.
我Google 翻译的
这 可以 被用来 覆盖 用户的首选 亮度 在屏幕上。 值 小于0 时, 默认情况下, 意味着 使用
首选 的 屏幕亮度 。 0到1 调整亮度 暗 到 全亮 。
//背光的亮度的设置
WindowManager.LayoutParams lp = getWindow().getAttributes();
if(viewModel.getScreenMode()==Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC){
lp.screenBrightness = -1.0f;
}else{
lp.screenBrightness = viewModel.getScreenBrightness()/255f;
}
getWindow().setAttributes(lp);