popup window点击窗口外区域不消失的解决方法

方法其实so easy:

popupWindow.setTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);

不行还可以加上:

popupWindow.setTouchInterceptor(new OnTouchListener() {
	public boolean onTouch(View v, MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
			popupWindow.dismiss();
			return true;
		}
		return false;
	}
});




你可能感兴趣的:(移动开发)