How to disable views behind a popup popup - android

I have a relative popup layout that displays when a button is clicked. I have other views on one screen, and a pop-up window covers them. But when I click on the popup, the controls / views behind get a click. How to disable this?

(One solution is to get all views and setClickable = false .)

But I'm looking for another solution, for example, to focus on the current view, so that other views are disabled.

+6
source share
4 answers

Use dialogue. I think this is the best solution for pop-ups.

 final Dialog dialog = new Dialog(NewEntryActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.interview_tab6_popup_drink_containg_alcohol); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); 
+2
source

I had the same problem and finally, instead of setting everything behind as clickable = false, I just added clickable = true to the popup layout and it fixed it. Click-through views beyond the pop-up window no longer respond to click events through the pop-up window. :) And I didn’t even have to change the pop-up in the dialog box. :)

+5
source

Activate setOnClickListener () in the RelativeLayout object. This allows access to all clicks and prevents clicks on management / viewing.

eg: -

  RelativeLayout rObj = (RelativeLayout) findViewById(R.id.yourRelativeLayout); rObj.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // filter touches when underlying view is Obscured by this view. } }); 
+2
source

To do this, do RelativeLayout BringToFront()

and make other representations SetEnabled(false)

+1
source

Source: https://habr.com/ru/post/927625/


All Articles