2011-09-08 80 views
2

我想要一個使用SeekBar調整屏幕亮度的對話框。如何在Android中設置屏幕亮度?

如何顯示調整屏幕亮度的自定義對話框SeekBar

+2

你可以用」 t在全球範圍內調整屏幕亮度;注意這個問題http://stackoverflow.com/questions/6158628/android-short-screen-brightness-code –

+0

是啊..它只適用於你的窗口。 – Ronnie

回答

4

You can use this API。這將改變你的窗口而不是整個系統的屏幕亮度。

 // Make the screen full bright for this activity. 
     WindowManager.LayoutParams lp = getWindow().getAttributes(); 
     lp.screenBrightness = 1.0f; 

     getWindow().setAttributes(lp); 
2

code snippet應該可以幫助您

pdlg = ProgressDialog.show(getParent(), "Loading...", ""); 
WindowManager.LayoutParams lp = pdlg.getWindow().getAttributes(); 
p.dimAmount=0.0f;  //Dim Amount 
pdlg.getWindow().setAttributes(lp); //Applying properties to progress dialog 
pdlg.dismiss(); //Dismiss the dialog 
1

嘿,你可以設置系統,亮度是這樣的:

//Set the system brightness using the brightness variable value 
System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness); 
//Get the current window attributes 
LayoutParams layoutpars = window.getAttributes(); 
//Set the brightness of this window 
layoutpars.screenBrightness = brightness/(float)255; 
//Apply attribute changes to this window 
window.setAttributes(layoutpars); 

或者,你可以參考這個完整tutorial