如何在Android中设置屏幕亮度?

时间:2011-09-08 04:20:40

标签: android screen-brightness

我想要一个使用SeekBar调整屏幕亮度的对话框。

如何使用调整屏幕亮度的SeekBar显示自定义对话框?

3 个答案:

答案 0 :(得分: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);

答案 1 :(得分: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

答案 2 :(得分: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