Android screen brightness Max Value?
-
26-06-2021 - |
题
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 1F;
getWindow().setAttributes(layout);
I added this code to button onClick and it worked ! But is there a higher value since the screen didn't light MAX ??
解决方案
As stated in the documentation, no. Setting screenBrightness
to 1 should adjust the brightness to full light.
其他提示
You should be able to set the value as 1L and it should go to max brightness as this is the max brightness
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 1F;
getWindow().setAttributes(layout);
Will set it to max brightness..
You should disable screen dimming first before you set the brightness, or you may get a less than MAX brightness ! Try something like this before you set the brightness:
// disable screen dimming (note - this also requires setting in manifest file)
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
A full example shows how to change brightness by coding, foreground, background. brightnessdemo
You Use this code
float SysBackLightValue = 255f;
android.provider.Settings.System.putInt(BatteryBoosterActivity.this.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,(int) SysBackLightValue);
Window myWindow =BatteryBoosterActivity.this. getWindow();
WindowManager.LayoutParams winParams = myWindow.getAttributes(); winParams.screenBrightness = 255f;
myWindow.setAttributes(winParams);
不隶属于 StackOverflow