Search code examples
androidseekbarbrightnessscroller

How could you increase the screen brightness in Android using a seek bar?


I would like to increase the brightness of the screen using a seek bar within my Android application, but I'm not sure how to do this. How can I add this functionality?


Solution

  • Using this you can set the screen brightness:

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

    Now, as you want to implement progress bar like control, i would suggest you to implement SeekBar, so using this you can easily increase/decrease based on tracking value of seekbar.

    Here is the full example implemented using the SeekBar.