Android 无法获取Popupwindow的外部接触事件

Android 无法获取Popupwindow的外部接触事件,android,popupwindow,Android,Popupwindow,我无法接触我的自定义弹出窗口,我的弹出窗口应该是可聚焦的,因为它有一些编辑文本,需要软键盘 这是我的密码: mPopupWindowAddnewItem= new PopupWindow(mPopupView, mView_add_Popup.getWidth(), LayoutParams.WRAP_CONTENT, true); mPopupWindowAddnewItem.setContentView(mPopupView);

我无法接触我的自定义弹出窗口,我的弹出窗口应该是可聚焦的,因为它有一些编辑文本,需要软键盘

这是我的密码:

        mPopupWindowAddnewItem= new PopupWindow(mPopupView,
                mView_add_Popup.getWidth(), LayoutParams.WRAP_CONTENT, true);
        mPopupWindowAddnewItem.setContentView(mPopupView);
        mPopupWindowAddnewItem.setFocusable(true);
        mPopupWindowAddnewItem.setOutsideTouchable(true);
        mPopupWindowAddnewItem.setBackgroundDrawable(new BitmapDrawable());
        mPopupWindowAddnewItem.setTouchInterceptor(new OnTouchListener() {

            @Override
            public boolean onTouch(View view, MotionEvent motion) {
                // TODO Auto-generated method stub

                if(motion.getAction()== MotionEvent.ACTION_OUTSIDE){
                    showExistDialog();

                    return true;
                }
                else
                if(motion.getAction() ==MotionEvent.ACTION_DOWN){
                    Rect mPopupRect=new Rect();
                    mPopupWindowAddnewItem.getContentView().getDrawingRect(mPopupRect);

                    if(mPopupRect.contains((int) motion.getRawX(),
                                    (int) motion.getRawY())){

                        return false;

                    }else{

                        showExistDialog();

                        return true;
                    }
                }

                return false;
            }
        });


        mPopupWindowAddnewItem.showAsDropDown(mView_add_Popup);
在我的代码中,它总是转到inside else if条件,而且弹出视图的rect检查总是返回false,即使我在触摸PopWindow内部。
有什么解决办法吗?

我已通过以下代码解决了我的问题:

else if(motion.getAction() ==MotionEvent.ACTION_DOWN){
                    Rect mPopupRect=new Rect();
                    mPopupWindowAddnewItem.getContentView().getDrawingRect(mPopupRect);

                    if(mPopupRect.contains((int)motion.getX(),
                                    (int) motion.getY())){

                        return false;

                    }else{

                        showExistDialog();

                        return true;
                    }
                }