如何消费,当外界点击驳回PopupWindow?外界、PopupWindow

2023-09-06 13:54:54 作者:少年痴货最帅比@

我目前正在设计使用 PopupWindow 类简单的提示弹出。我能在内容之外点击关闭该弹出窗口。然而,触摸事件以外由下划线布局消耗。我怎样才能消耗掉外界接触,这样,当外界点击我仍然弹出驳回,但也有被发送到布局低于我的 PopupWindow ?

当前设置属性:的

mPopupWindow.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_bg)); mPopupWindow.setOutsideTouchable(真正的);

解决方案

原来是有办法做到这一点!细算深入PopupWindow和ListPopupWindow我发现了选项 setFocusable(真);!将不正是我需要的。

I'm currently designing simple tips popups using the PopupWindow class. I'm able to dismiss the popup when clicked outside of the content. However the touch events outside are consumed by the underlining layout. How can I consume the outside touches so that when clicked outside I still have the popup dismissed but there are no touch events being sent to the layout below my PopupWindow?

想到啥写啥第一期 Android的菜单popupMenu和PopupWindow

Current set properties:

mPopupWindow.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.popup_bg));
mPopupWindow.setOutsideTouchable(true);

解决方案

Turns out there is a way to do it! After looking deep into PopupWindow and ListPopupWindow I discovered the option setFocusable(true); will do exactly what I needed!