@Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            dismiss();
            return true;
        }
        return false;
    }
The dialog class showing the context menu and ensures proper animation is played upon calling
{@link #show()} and {@link #dismiss()}.
customtabs/src/android/support/customtabs/browseractions/BrowserActionsFallbackMenuDialog.java