<pre name="code" class="java">1.点击popwindow 以外的区域隐藏
使其聚焦
popupWindow.setFocusable(true);
设置允许在外点击消失
popupWindow.setOutsideTouchable(true);
2.点击"返回Back"也能使其消失,并且不会影响你的背景
popupWindow.setBackgroundDrawable(new BitmapDrawable());
3.点击popwindow自身的时候隐藏
popupWindow_view.setOnTouchListener(new OnTouchListener() {

public boolean onTouch(View arg0, MotionEvent arg1) {

if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
return true;
}
return false;
}
});