PopupWindow - 辞退当外界点击 [英] PopupWindow - Dismiss when clicked outside
问题描述
我有我的活性PopupWindow,事情是我PopupWindow还表示,即使当我跟我的互动活动(比如滚动我的列表)。我可以通过我的列表中滚动和PopupWindow仍然存在。
I have a PopupWindow on my activity, the thing is my PopupWindow still shows even when I'm interacting with my activity (say scrolling on my list). I can scroll through my list and the PopupWindow is still there.
当我触摸/滚动/点击的/ etc这不是PopupWindow在屏幕上,我想驳回PopupWindow我想实现的是。就像如何菜单的工作原理。如果您单击菜单之外,菜单将被开除。
What I want to achieve is when I'm touching/scrolling/clicking/etc on the screen which is not the PopupWindow, I want to dismiss the PopupWindow. Just like how a menu works. If you clicked outside of the menu, the menu will be dismissed.
我已经试过 setOutsideTouchable(真)
但不会关闭该窗口。谢谢你。
I've tried setOutsideTouchable(true)
but it won't dismiss the window. Thanks.
推荐答案
请尝试在PopupWindow,如果你在它之外触及应该关闭该窗口中设置setBackgroundDrawable。
Please try to set setBackgroundDrawable on PopupWindow that should close the window if you touch outside of it.
这篇关于PopupWindow - 辞退当外界点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!