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

来源:互联网 发布:飞鸽传书经典mac 编辑:程序博客网 时间:2024/05/23 05:09

方法其实so easy:

[java] view plain copy
  1. popupWindow.setTouchable(true);  
  2. popupWindow.setFocusable(true);  
  3. popupWindow.setBackgroundDrawable(new BitmapDrawable());  
  4. popupWindow.setOutsideTouchable(true);  

不行还可以加上:

[java] view plain copy
  1. popupWindow.setTouchInterceptor(new OnTouchListener() {  
  2.     public boolean onTouch(View v, MotionEvent event) {  
  3.         if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {  
  4.             popupWindow.dismiss();  
  5.             return true;  
  6.         }  
  7.         return false;  
  8.     }  
  9. });  
0 0
原创粉丝点击