How to dim a screen on click of a button in android?

SANDHYA picture SANDHYA · May 30, 2012 · Viewed 8.3k times · Source

How do i darken/dim the current screen on click of a button. PLease help me.

Answer

cytinus picture cytinus · May 30, 2012
WindowManager.LayoutParams lparams = getWindow().getAttributes();  
lparams.dimAmount=1.0f; 
dialog.getWindow().setAttributes(lparams);  

The dim amount 0 means no dimming, and the dim amount 1.0f means complete dimming. Any value in between is the corresponding percentage of dim.

Just add this code to the button you want.