如何消费,当外界点击驳回PopupWindow? [英] How to consume and dismiss the PopupWindow when clicked outside?

查看:119
本文介绍了如何消费,当外界点击驳回PopupWindow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

当前设置属性:

<$p$p><$c$c>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?

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!

这篇关于如何消费,当外界点击驳回PopupWindow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆