Search code examples
androidparenttouch-event

How to pass the control from child to parent


I am having a problem when I am working with both the horizontal-page flip and the pinch zoom with drag.How to pass the touch event from child to the parent.I want the control back to the parent when the image is not in the zoom.can anyone help me how to pass the Touch-event Control to the parent


Solution

  • Try this snippet of code

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mMove.track(event)){
               if (mMove.getDirection() == Direction.VERTICAL){
                  getParent().requestDisallowInterceptTouchEvent(true);
    
               }
         } 
         return true;
    }
    
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        // TODO Auto-generated method stub
        return false;
    }
    

    Refer this link for more details