I'm trying to achieve something pretty specific and cannot find a proper answer in SO or Google.
I have a ViewPager displaying fragments on swipe (left <-> right), working perfectly.
I need the entire screen to intercept swipe-down touch events, and the ViewPager to keep intercepting left-right swiping.
Basically, if the user swipe in left <-> right direction on the ViewPager, it handles it normally, but if user swipe down (on ViewPager or anywhere else), I need to trigger other behavior.
I've read a lot about onInterceptTouchEvent()
, but I don't really understand how it works...
Here's my viewpager_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dialog_root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/dialog_tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorDark"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="1dp"/>
<android.support.v4.view.ViewPager
android:id="@+id/dialog_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorDark"/>
</LinearLayout>
</RelativeLayout>
I didn't post any of my Java code, because it's a simple implementation of ViewPager, but if you need any additional information I will be glad to edit my question.
Thank you!