Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:44:42+00:00 2026-05-27T05:44:42+00:00

I have implemented a custom dialog for my application. I want to implement that

  • 0

I have implemented a custom dialog for my application. I want to implement that when the user clicks outside the dialog, the dialog will be dismissed.
What do I have to do for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:44:43+00:00Added an answer on May 27, 2026 at 5:44 am

    You can use dialog.setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog.

    Something like,

      Dialog dialog = new Dialog(context)
      dialog.setCanceledOnTouchOutside(true);
    

    Or if your Dialog in non-model then,

    1 – Set the flag-FLAG_NOT_TOUCH_MODAL for your dialog’s window attribute

    Window window = this.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    

    2 – Add another flag to windows properties,, FLAG_WATCH_OUTSIDE_TOUCH – this one is for dialog to receive touch event outside its visible region.

    3 – Override onTouchEvent() of dialog and check for action type. if the action type is
    ‘MotionEvent.ACTION_OUTSIDE‘ means, user is interacting outside the dialog region. So in this case, you can dimiss your dialog or decide what you wanted to perform.
    view plainprint?

    public boolean onTouchEvent(MotionEvent event)  
    {  
    
           if(event.getAction() == MotionEvent.ACTION_OUTSIDE){  
            System.out.println("TOuch outside the dialog ******************** ");  
                   this.dismiss();  
           }  
           return false;  
    }  
    

    For more info look at How to dismiss a custom dialog based on touch points? and
    How to dismiss your non-modal dialog, when touched outside dialog region

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking to implement a custom class of : IList<ArraySegment<byte>> this will
I have implemented custom errors in my asp.net mvc application by following this article
I have a custom class that implements that IComparable. This class is stored in
I have a custom class that implements ICollection , and this class is readonly,
In my application I have a Seekbar that is shown in a dialog. Now
I have implemented a custom IPrincipal that I set in protected void Application_PostAuthenticateRequest(Object sender,
I have decided that I wanted to create some custom dialog classes that could
We have implemented some custom tooltip-drawing code that fires on Tick events of a
I have a control derived from a CWnd object that has its custom implemented
I have implemented a custom ActionMapper which obtains the locale from the URI (the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.