简体   繁体   中英

Android screen brightness Max Value?

    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");

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);

A full example shows how to change brightness by coding, foreground, background. brightnessdemo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM