2012-08-15 108 views
8
WindowManager.LayoutParams layout = getWindow().getAttributes(); 
    layout.screenBrightness = 1F; 
    getWindow().setAttributes(layout); 

我將此代碼添加到按鈕onClick,它的工作! 但是有沒有更高的值,因爲屏幕沒有點亮MAX?Android屏幕亮度最大值?

回答

4

As stated in the documentation,no。將screenBrightness設置爲1應將亮度調整爲全亮。

+0

一個很好的使用方法是使用常量'BRIGHTNESS_OVERRIDE_FULL'。它的值是1.0f – Cristan 2017-11-28 14:56:43

1

您應該能夠設定值1L和它應該到最大亮度,因爲這是最大亮度

WindowManager.LayoutParams layout = getWindow().getAttributes(); 
layout.screenBrightness = 1F; 
getWindow().setAttributes(layout); 

將其設置爲最大亮度..

0

,應禁用屏幕在設置亮度之前先調暗,否則可能會出現小於最大亮度!嘗試這樣的事情你設置亮度前:

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

您使用此代碼

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