Home » Android » Close custom popup when it pressed outsided of the popup [duplicate]

Close custom popup when it pressed outsided of the popup [duplicate]

Posted by: admin November 1, 2017 Leave a comment

Questions:

This question already has an answer here:

Answers:

Use

setCanceledOnTouchOutside(true)

See Android developer documentation.

And create your Dialog like shown here, using an AlertDialog.Builder. This class offers the same constructor parameters as your utilized Dialog.

Additionally, this question already has an answer.

Questions:
Answers:

Three changes to be made before showing the Dialog:

 dialog.setCanceledOnTouchOutside(true);
 setCancelable(boolean)

The last thing that may help is to go to the layout popup_base_menu and change the root view height and width to:

 wrap_content

It should instead of match_parent.
All this change should be called before dialog.show();