Question

Je veux une boîte de dialogue qui ajuste la luminosité de l'écran à l'aide SeekBar.

Comment afficher dialogue personnalisé avec SeekBar qui ajuste la luminosité de l'écran?

Était-ce utile?

La solution

Vous pouvez utiliser cette API . Cela va changer la luminosité de l'écran de votre fenêtre et non de l'ensemble du système.

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

        getWindow().setAttributes(lp);

Autres conseils

extrait de code devrait vous aider

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

Hé, vous pouvez régler la luminosité du système comme celui-ci:

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

Ou vous pouvez consulter sur ce complet tutoriel

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top