1

Is it possible to remove scroll event for a layout that is inside a ScrollView?

I have the following layout hierarchy:

ScrollView

  RelativeLayout

    LinearLayout

      TableLayout

    RelativeLayout

      GestureOverlayView

I want to remove the scroll event for the RelativeLayout that contains a GestureOverlayView so that when the user draws a vertical line, the event is not intercepted as scroll but as drawing.

blavi
  • 531
  • 1
  • 10
  • 26

1 Answers1

3

I don'y know you still need that or not but here is the answer I tested. this is how you prevent the parent View from stealing touchEvent of a child view:

childView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (v.getId() == R.id.childView) {
                v.getParent().requestDisallowInterceptTouchEvent(true);
                switch (event.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_UP:
                        v.getParent().requestDisallowInterceptTouchEvent(false);
                        break;
                }
            }

            return false;
        }
    });

you can go up in parents by:

v.getParent().getParent ....
Ashkan.H
  • 121
  • 1
  • 10