Android的弹出窗口时,驳斥外界点击 [英] Android Popup Window dismisses when clicked outside
问题描述
我希望得到的答案,我的问题,我目前所面对的。
I was hoping to get an answer to my problem I have at the moment.
我有延伸弹出窗口的类。它工作正常,但我不想解雇,当我点击窗口外的窗口。
I have a class which extends popup window. It works fine except I don't want the window to dismiss when I click outside of the window.
目前,我有 setOutsideTouchable(假);
但这只是停止窗外的事件,它仍然驳回弹出
At the moment I have setOutsideTouchable(false);
but this just stops events outside the window, it still dismisses the popup.
一个对话框有 setCanceledOnTouchOutside(假)
,有没有类似的东西,我可以使用?
A dialog has setCanceledOnTouchOutside(false)
, is there something similar I can use?
感谢
推荐答案
确定这样固定到底。
首先取得该弹出坐落在一个相对布局的主要布局。然后放置在顶部全屏留白的布局设计,我不可见,透明。
First made the main layout which the popup sits on a relative layout. Then placed a full screen blank layout on top which I made invisible and transparent.
然后显示弹出显示时,设置全屏幕面板 setVisibility(View.VISIBLE)可见;
和隐藏弹出时被隐藏与 setVisibility(View.GONE);
Then show when the popup is shown, set the full screen panel visible with setVisibility(View.VISIBLE);
and hide when popup is hidden with setVisibility(View.GONE);
也需要从返回true触摸侦听器的布局(停止触摸事件传递回主布局):
Also need to return true from an on touch listener for the layout with (To stop touch events passing back to the main layout):
blocker.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
和给弹出窗口属性:
setTouchable(true);
setOutsideTouchable(false);
干杯
这篇关于Android的弹出窗口时,驳斥外界点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!