2011-10-21 38 views

回答

4

progress範圍默認值,您可以設置屏幕亮度:

WindowManager.LayoutParams lp = getWindow().getAttributes(); 
lp.screenBrightness = 100/100.0f; 
getWindow().setAttributes(lp); 

現在,只要你想實現像控制進度條,我建議你實現搜索欄,所以使用這個你可以很容易地增加/減少seekbar的跟蹤值。

Here是使用SeekBar實現的完整示例。

+0

但屏幕亮度條消失。如何不讓它消失? –

1

使用此更改亮度(系統級)

ContentResolver cr = getContentResolver(); 
int brightness = Settings.System.getInt(cr,Settings.System.SCREEN_BRIGHTNESS);    
Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness); 
WindowManager.LayoutParams lp = getWindow().getAttributes(); 
lp.screenBrightness = brightness/255.0f; 
getWindow().setAttributes(lp); 

您可以使用this example並調用上面的代碼中onProgressChanged()。使用這種從0到100

0

您可以使用WindowManager.LayoutParams更改屏幕亮度。 使用getWindow().getAttributes()獲取LayoutParams,然後將字段screenBrightness設置爲0到1之間的數字(0黑暗,1亮),然後使用修改過的LayoutParams對象調用getWindow().setAttributes()