1 如何实现点击popup外边来实现,popupWindow自动退出
a 设置外部可点击
popupWindow = new PopupWindow(menuView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); popupWindow.setOutsideTouchable(true);
b 复写touch方法 ,让布局中的其他背景空间,都来坚挺touch事件
relativeLayout.setOnTouchListener(this) ; skiiBgImageView.setOnTouchListener(this) ;
@Override public boolean onTouch(View v, MotionEvent event) { Log.d("touch", v.toString()) ; if ((popupWindow!=null) && (popupWindow.isShowing())) { popupWindow.dismiss() ; } return false; }
2 popupwindow 的窗口泄露
一定要将popwindow dismiss 之后,在去做activity.finish()