我在我的应用中使用弹出窗口。我想在用户触摸窗外时关闭窗口。我已经为下面的代码和它的工作编写了以下代码。但问题是当我试图滚动窗口本身取消时,我的窗口内有一个滚动视图。我怎么能防止这种情况?
mInflater = (LayoutInflater) getActivity()
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View layout = mInflater.inflate(R.layout.help_popup,
null);
mHelpPopup = new PopupWindow(layout, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
mHelpPopup.setOutsideTouchable(true);
mHelpPopup.setTouchable(true);
mHelpPopup.setBackgroundDrawable(new BitmapDrawable());
mHelpPopup.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Logger.get().d("POPUP_WINDOW", "v: " + v.getTag() + " | event: " + event.getAction());
mHelpPopup.dismiss();
return true;
}
});
mHelpPopup.showAtLocation(layout, Gravity.CLIP_VERTICAL, (int) helpTxtView.getX(), (int) helpTxtView.getY());
答案 0 :(得分:0)
我能找到答案。这是因为touchinterceptor。当我删除那个听众它工作正常。