如何在Android上打开PopupWindow并让所有其他组件可触摸而不关闭PopupWindow?
它是这样创建的:
public class DynamicPopup {
private final PopupWindow window;
private final RectF rect;
private final View parent;
private final RichPageView view;
public DynamicPopup(Context context, RichPage page, RectF rectF, View parent) {
this.parent = parent;
rect = rectF;
window = new PopupWindow(context);
window.setBackgroundDrawable(new BitmapDrawable());
window.setWidth((int) rect.width());
window.setHeight((int) rect.height());
window.setTouchable(true);
window.setFocusable(true);
window.setOutsideTouchable(true);
view = new RichPageView(context, page, false);
window.setContentView(view);
view.setOnCloseListener(new Listener(){
@Override
public void onAction() {
window.dismiss();
}
});
}
public void show() {
window.showAtLocation(parent, Gravity.NO_GRAVITY, (int) rect.left, (int) rect.top);
}
}
就像 ernazm 所说的
根据javadoc
控制弹出窗口是否会收到其窗口之外的触摸事件的通知。这仅对可触摸的弹出窗口有意义但无法对焦
它正在努力
window.setTouchable(true);
window.setFocusable(false);
window.setOutsideTouchable(false);
当 window touchalbe 为 true,focusable 为 false 时,setOutsideTouchable() 起作用,如果 setOutsideTouchable(true),popupwindow 外部的触摸将关闭,否则 popupwindows 外部仍然可以触摸而不关闭。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)