如何打開Android上的PopupWindow並讓所有其他組件觸摸而不關閉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);
}
}
您是否試過這種方法? http://developer.android。com/reference/android/widget/PopupWindow.html#setOutsideTouchable%28boolean%@ – ernazm
@ernazm,您應該將其移至答案。 – Phil
嗯,我不確定這種方法是否按預期工作,因爲我沒有使用它(android SDK有很多bug的東西tbh),這個問題已經提出。 – ernazm