Android popup rejects when clicking on it

I was hoping to get an answer to my problem that I have at the moment.

I have a class that extends a popup. It works great, except that I don't want the window to tilt when I click the button outside the window.

At the moment I have setOutsideTouchable(false); but it just stops events outside the window, but still rejects the popup.

There is setCanceledOnTouchOutside(false) in the dialog box, is there something similar that I can use?

thanks

+6
source share
2 answers

Ok, so fixed at the end.

First, a basic layout was made that pops up on a relative layout. Then I placed the full screen blank layout on top, which I made invisible and transparent.

Then show when the popup is displayed, set the full-screen panel using setVisibility(View.VISIBLE); and hide when the popup is hidden using setVisibility(View.GONE);

You must also return true from the touch listener for the layout using (To stop touch events returning to the main layout):

 blocker.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); 

And give the popup properties:

 setTouchable(true); setOutsideTouchable(false); 

Greetings

+6
source

What are you using this PopupWindow ? It looks like you are using it in more than the Dialog way.

In doing so, you will probably have to examine setTouchInterceptor and then create your own OnTouchListener , which you will use to check where the touch was made (in Popup or not).

0
source

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


All Articles