Search code examples
androidtouchscrollviewhorizontalscrollviewviewgroup

HorizontalScrollView inside Movable View


I have a movableView(moves with finger touch movement) of 400*400, it has a horizontal view at bottom (400*100). When I want to scroll horintalScrollView to see the list, my movableView is moving, but horintalSrollView is not taking any touchEvent.

I want it like, when I am touching horizontalScrollView, only it should scroll. And when not touching it and want to move my movableView it should move.

Any suggestions would be helpful. Thanks


Solution

  • Try this logic...

    scrollView.setOnTouchListener(new OnTouchListener() {
    // Setting on Touch Listener for handling the touch inside movableView
    @Override
    public boolean onTouch(View v, MotionEvent event) {
    // Disallow the touch request for parent move on touch of child view
    v.getParent().requestDisallowInterceptTouchEvent(true);
    return false;
    }
    });