Code example for PopupWindow

Methods: setTouchInterceptor

0
    private View root;
    private Drawable background = null;
    protected final WindowManager mWManager;
 
    public CustomPopup(View anchor) {
        mAnchor = anchor;
        mWindow = new PopupWindow(anchor.getContext());
 
        mWindow.setTouchInterceptor(new OnTouchListener() {
 
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    CustomPopup.this.dismiss();
                    return true; 
                } 
                return false; 
            } 
        }); 
 
        mWManager = (WindowManager) anchor.getContext().getSystemService(
Connect your IDE to all the code out there  Get Codota for Java