I have a nested ViewPager that works brilliantly. The only issue is, once the child ViewPager is at the last item and I scroll further, the parent ViewPager scrolls. I do not want this behaviour.
How do I achieve this?
Here is an example, in my Activity_main.xml I have the parent ViewPager, which houses three fragment pages.
 <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Inside one of the fragment layouts, fragment_categories.xml, I have another ViewPager, which is a child to the parent viewPager in the Activity_main.xml,
<android.support.v4.view.ViewPager
    android:id="@+id/mViewPager"
    android:layout_width="match_parent"
    android:layout_height="@dimen/offer_height"
    android:layout_marginTop="2dp"
    android:overScrollMode="never"/>
It all works fine. But when the child viewPager reaches its last item, and I scroll more, the parent viewPager moves to the next page. I do not want this. I tried doing this by intercepting touch on the parent ViewPager before, and that didn't work. I'm guessing I'm doing it wrong? (Yes, I changed tags in the xml to com.project.CustomViewPager and tried this.)
CustomViewPager.java:
  public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
        if(v != this && v instanceof ViewPager) {
            return false;
        }
        return super.canScroll(v, checkV, dx, x, y);
    }