Tap outside Android dialog to dismiss it?

Michell Bak picture Michell Bak · Aug 27, 2011 · Viewed 32.4k times · Source

I was wondering if it's possible to somehow tap outside a popup dialog (or an Activity with a dialog theme), and dismiss it by just tapping outside of it?

I made a quick picture to illustrate it:

enter image description here

Normally, you have to press the back key to dismiss the dialogs, but on Honeycomb it could be great to have the option of just tapping outside the dialog, due to all the screen estate.

Answer

Francesco Vadicamo picture Francesco Vadicamo · Dec 5, 2011
dialog.setCanceledOnTouchOutside(true) 

Sets whether this dialog is canceled when touched outside the window's bounds.