title: ViewPager : swipe only from a particular view
body: <p>I have a created a custom viewpager, and i would like the user to swipe and change pages only from a part of the screen.</p>
  
  <p>Every page has a linearlayout at the bottom with some text, and i would like to swipe only from there, not from the hole screen.</p>
  
  <p>Is that possible?</p>
  
  <p>This is my custom viewpager class:</p>
  
  <pre><code>public class MyViewPager extends ViewPager {
  
      private boolean mSwipable = true;
  
      public MyViewPager(Context context) {
          super(context);
      }
  
      public MyViewPager(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent event) {
          return mSwipable ? super.onInterceptTouchEvent(event) : false;
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          return mSwipable ? super.onTouchEvent(event) : false;
      }
  
      public boolean isSwipable() {
          return mSwipable;
      }
  
      public void setSwipable(boolean swipable) {
          mSwipable = swipable;
      }
  }
  </code></pre>
  
  <p>and this is the view of a page:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/white"
      android:clipChildren="false"
      android:clipToPadding="false"
      android:fillViewport="true"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:showIn="@layout/fragment_search"&gt;
  
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_above="@+id/bottomLayout"
          android:layout_marginBottom="@dimen/bottom_bar_height"&gt;
  
        //show some stuff here
  
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/bottomMenu"
          android:layout_width="match_parent"
          android:layout_height="@dimen/bottom_bar_height"
          android:layout_alignParentBottom="true"
          android:layout_gravity="bottom"
          android:orientation="horizontal"&gt;
  
        // this is my footer, where i need to change the pages by swipe
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>