Вопрос

Я хочу диалог, который регулирует яркость экрана, используя SeekBar.

Как отобразить пользовательский диалог с SeekBar это регулирует яркость экрана?

Это было полезно?

Решение

Вы можете использовать этот API. Анкет Это изменит яркость экрана вашего окна, а не всю систему.

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

        getWindow().setAttributes(lp);

Другие советы

Этот код фрагмент должен вам помочь

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

Эй, ты можешь установить яркость системы так:

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

Или вы можете ссылаться на это полное руководство

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top