Search code examples
androidandroid-scrollview

Passing touch events to ScrollView's Parent


I have a layout similar to this:

<FrameLayout>
   <ScrollView>
      <RelativeLayout>
      </RelativeLayout>
   </ScrollView>
</FrameLayout>

I want ScrollView to work normally with Vertical gesture(scroll/fling) and Pass horizontal gestures to it's parent(FrameLayout has Drag functionality and works fine without a ScrollView).


Solution

  • You need to create a new class extending FrameLayout and ovverriding onInterceptTouchEvents than you can perform your logic and decide which events must be sent to the scrollview and which ones must be handle inside the FrameLayout onTouchEvent

    You can check the official documentation here