Search code examples
androiddialogandroid-activitytouch

How to cancel an Dialog themed like Activity when touched outside the window?


I have an activity with a Dialog theme and I would like to close (finish) this activity when someone touches the screen anywhere outside this activity's window ? How can I do this ?


Solution

  • If there's no API support, you should just use a FrameLayout to fill the screen, and manually build a pop-up. Then you can receive focus anywhere on the screen and show/hide views accordingly.