title: How to use viewpager inside nestedScrollView with a view top of viewpager
body: <p>I am unable to scroll nestedScrollView because of viewpager. So let me explain here is layout design that i want to create: </p>
  
  <p><a href="https://i.stack.imgur.com/BgQNK.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/BgQNK.jpg" alt="enter image description here"></a> </p>
  
  <p>There is FrameLayout inside NestedScrollView and a viewpager with tab layout. Viewpager load three fragments with endless recylerview (Pagination). </p>
  
  <p>Here is layout xml code :</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout 
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/background"
  tools:context="com.plowns.droidapp.activites.HomeActivity"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:id="@+id/appBarLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay"&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  
          &lt;/RelativeLayout&gt;
  
  
      &lt;/android.support.v7.widget.Toolbar&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="100dp"
      android:layout_marginTop="50dp"
      android:background="@color/colorPrimary" /&gt;
  
  
  &lt;android.support.v4.widget.NestedScrollView
      android:id="@+id/nestedscrollview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;FrameLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:background="@color/trans"&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="260dp"&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_marginTop="55dp"
                      app:cardCornerRadius="5dp"&gt;
  
                      &lt;RelativeLayout
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"&gt;
  
                          &lt;ImageView
                              android:id="@+id/txt_edit_icon"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_alignParentRight="true"
                              android:src="@drawable/ic_mode_edit"
                              android:tint="@color/blue_plowns" /&gt;
  
                          &lt;TextView
                              android:id="@+id/txt_child_name"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_centerHorizontal="true"
                              android:layout_marginTop="50dp"
                              android:ellipsize="end"
                              android:gravity="center_vertical"
                              android:minHeight="5dp"
                              android:text="Satwinder Singh"
                              android:textAppearance="?android:attr/textAppearanceListItemSmall"
                              android:textColor="@android:color/black"
                              android:textSize="18sp"
                              android:textStyle="bold" /&gt;
  
                          &lt;LinearLayout
                              android:id="@+id/ll_points_class"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_below="@+id/txt_child_name"
                              android:layout_centerHorizontal="true"
                              android:orientation="horizontal"&gt;
  
                              &lt;TextView
                                  android:id="@+id/txt_child_points"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_gravity="center_horizontal"
                                  android:text="10038"
                                  android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                  android:textColor="@color/gray"
                                  android:textSize="14sp" /&gt;
  
                              &lt;View
                                  android:id="@+id/point_class_sapretor"
                                  android:layout_width="1dp"
                                  android:layout_height="10dp"
                                  android:layout_gravity="center"
                                  android:layout_marginLeft="5dp"
                                  android:background="@color/gray" /&gt;
  
                              &lt;TextView
                                  android:id="@+id/txt_child_class"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginLeft="5dp"
                                  android:text="Collage"
                                  android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                  android:textColor="@color/gray"
                                  android:textSize="13sp" /&gt;
  
                          &lt;/LinearLayout&gt;
  
                          &lt;LinearLayout
                              android:id="@+id/ll_title"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:layout_below="@+id/ll_points_class"
                              android:layout_centerHorizontal="true"
                              android:orientation="horizontal"
                              android:visibility="gone"&gt;
  
                              &lt;TextView
                                  android:id="@+id/txt_title"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_gravity="center_horizontal"
                                  android:ellipsize="end"
                                  android:maxLines="1"
                                  android:singleLine="true"
                                  android:text=""
                                  android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                  android:textColor="@android:color/white"
                                  android:textSize="14sp" /&gt;
  
                          &lt;/LinearLayout&gt;
  
  
                          &lt;android.support.v7.widget.CardView
                              android:id="@+id/card_badge"
                              android:layout_width="100dp"
                              android:layout_height="20dp"
                              android:layout_below="@+id/ll_title"
                              android:layout_centerHorizontal="true"
                              android:layout_marginTop="5dp"
                              android:backgroundTint="@color/yellow_plowns"
                              app:cardCornerRadius="5dp"&gt;
  
                              &lt;TextView
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_gravity="center"
                                  android:text="BADGE WALL"
                                  android:textColor="@color/white"
                                  android:textSize="12sp"
                                  android:textStyle="bold" /&gt;
  
                          &lt;/android.support.v7.widget.CardView&gt;
  
                          &lt;LinearLayout
                              android:layout_width="match_parent"
                              android:layout_height="50dp"
                              android:layout_below="@+id/card_badge"
                              android:layout_centerHorizontal="true"
                              android:layout_marginLeft="10dp"
                              android:layout_marginRight="10dp"
                              android:layout_marginTop="5dp"
                              android:baselineAligned="false"
                              android:gravity="center"
                              android:orientation="horizontal"
                              android:weightSum="3"&gt;
  
                              &lt;RelativeLayout
                                  android:id="@+id/rl_upload"
                                  android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:layout_weight="1"
                                  android:paddingTop="5dp"&gt;
  
                                  &lt;TextView
                                      android:id="@+id/txt_upload_count"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_centerHorizontal="true"
                                      android:text="13"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/black"
                                      android:textSize="15sp"
                                      android:textStyle="bold" /&gt;
  
                                  &lt;TextView
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_below="@+id/txt_upload_count"
                                      android:layout_centerHorizontal="true"
                                      android:layout_marginTop="5dp"
                                      android:text="@string/profile_title_uploads"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/gray"
                                      android:textSize="13sp" /&gt;
  
                                  &lt;View
                                      android:layout_width="1dp"
                                      android:layout_height="40dp"
                                      android:layout_alignParentRight="true"
                                      android:layout_centerVertical="true"
                                      android:background="@color/gray" /&gt;
  
  
                              &lt;/RelativeLayout&gt;
  
                              &lt;RelativeLayout
                                  android:id="@+id/rl_followers"
                                  android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:layout_weight="1"
                                  android:paddingTop="5dp"&gt;
  
                                  &lt;TextView
                                      android:id="@+id/txt_follower_count"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_centerHorizontal="true"
                                      android:text="13"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/black"
                                      android:textSize="15sp"
                                      android:textStyle="bold" /&gt;
  
                                  &lt;TextView
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_below="@+id/txt_follower_count"
                                      android:layout_centerHorizontal="true"
                                      android:layout_marginTop="5dp"
                                      android:text="@string/profile_title_followers"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/gray"
                                      android:textSize="13sp" /&gt;
  
                                  &lt;View
                                      android:layout_width="1dp"
                                      android:layout_height="40dp"
                                      android:layout_alignParentRight="true"
                                      android:layout_centerVertical="true"
                                      android:background="@color/gray" /&gt;
  
                              &lt;/RelativeLayout&gt;
  
                              &lt;LinearLayout
                                  android:id="@+id/ll_following"
                                  android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:layout_weight="1"
                                  android:gravity="center"
                                  android:orientation="vertical"&gt;
  
                                  &lt;TextView
                                      android:id="@+id/txt_following_count"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:text="47"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/black"
                                      android:textSize="15sp"
                                      android:textStyle="bold" /&gt;
  
                                  &lt;TextView
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_marginTop="5dp"
                                      android:text="@string/profile_title_following"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@color/gray"
                                      android:textSize="13sp" /&gt;
  
  
                              &lt;/LinearLayout&gt;
  
                          &lt;/LinearLayout&gt;
  
                          &lt;LinearLayout
                              android:layout_width="match_parent"
                              android:layout_height="25dp"
                              android:layout_alignParentBottom="true"
                              android:background="@color/colorPrimary"
                              android:orientation="horizontal"&gt;
  
                              &lt;LinearLayout
                                  android:id="@+id/ll_share"
                                  android:layout_width="0dp"
                                  android:layout_height="match_parent"
                                  android:layout_weight="0.5"
                                  android:gravity="center"
                                  android:orientation="horizontal"&gt;
  
                                  &lt;TextView
                                      android:id="@+id/txt_share_icon"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:gravity="center"
                                      android:text="&amp;#xf0c0;"
                                      android:textColor="@color/pink"
                                      android:textSize="15sp" /&gt;
  
                                  &lt;TextView
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_marginLeft="10dp"
                                      android:gravity="center"
                                      android:text="Invite friends"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@android:color/white"
                                      android:textSize="14sp" /&gt;
  
                              &lt;/LinearLayout&gt;
  
                              &lt;LinearLayout
                                  android:id="@+id/ll_switch_child"
                                  android:layout_width="0dp"
                                  android:layout_height="match_parent"
                                  android:layout_weight="0.5"
                                  android:gravity="center"
                                  android:orientation="horizontal"&gt;
  
                                  &lt;ImageView
                                      android:id="@+id/txt_switch_child_icon"
                                      android:layout_width="22dp"
                                      android:layout_height="22dp"
                                      android:background="@drawable/ic_switch"
                                      android:textAllCaps="false"
                                      android:textColor="@color/white" /&gt;
  
                                  &lt;TextView
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:layout_marginLeft="10dp"
                                      android:gravity="center"
                                      android:text="Switch profile"
                                      android:textAppearance="?android:attr/textAppearanceListItemSmall"
                                      android:textColor="@android:color/white"
                                      android:textSize="14sp" /&gt;
  
                              &lt;/LinearLayout&gt;
  
                          &lt;/LinearLayout&gt;
  
                      &lt;/RelativeLayout&gt;
  
                  &lt;/android.support.v7.widget.CardView&gt;
  
              &lt;/FrameLayout&gt;
  
              &lt;de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                  android:id="@+id/img_child_profile"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:layout_gravity="top|center_horizontal"
                  android:layout_marginTop="5dp"
                  android:src="@drawable/blank_profile"
                  app:border_color="@color/colorPrimary"
                  app:border_width="2dp" /&gt;
  
          &lt;/FrameLayout&gt;
  
  
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/card_bottom"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="10dp"
              app:cardCornerRadius="5dp"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical"&gt;
  
                  &lt;android.support.design.widget.TabLayout
                      android:id="@+id/tabs"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="@color/white"
                      app:tabGravity="fill"
                      app:tabIndicatorColor="@color/colorPrimary"
                      app:tabIndicatorHeight="0dp"
                      app:tabMode="fixed"
                      app:tabSelectedTextColor="@color/white"
                      app:tabTextColor="@color/white" /&gt;
  
                  &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:background="@color/gray" /&gt;
  
                  &lt;android.support.v4.view.ViewPager
                      android:id="@+id/viewpager"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/android.support.v7.widget.CardView&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/android.support.v4.widget.NestedScrollView&gt;
  </code></pre>
  
  <p></p>
  
  <p>Now when i scroll outside of viewpager nothing happened (view not scroll). And on viewpager scroll only recyclerview scroll. But I want to scroll the whole view on outside frame layout scroll and on recylerview also.  </p>
  
  <p><strong>What I have tried :</strong></p>
  
  <p><strong>1)</strong> Set fixed height for Viewpager(700dp). <strong>Result:</strong> Scroll on Framelayout smoothly worked but Scroll on Recyclerview is not worked correctly and smooth. I have to scroll many time to scroll.</p>
  
  <p><strong>2)</strong> Set Framelayout &amp; Tablayout inside AppBarLayout. <strong>Result:</strong> Scroll Up worked smoothly but On Scroll down Recylerview(Viewpager), first Appbarlayout is fully scrolled down and then Recyclerview content scrolled that was behind Appbarlayout. So I have to scroll down the whole list to see first contents it is a bad experience.</p>
  
  <p><strong>3.)</strong> Created custom Viewpager as suggested here like <a href="https://stackoverflow.com/a/41587367/6219121">enter link description here</a>
   <strong>Result :</strong> Same as 1st case:</p>
  
  <p><strong>4)</strong> Disabled Touch on Viewpager and use custom Viewpager. <strong>Result:</strong> Smoothly scrolled whole view but due to touch disabled on Viewpager I am unable to paginate Recyclerview means have to check every touch type and detect the end of the scroll to load next data in Recyclerview. I do not want to do this. </p>
  
  <p>So here is my problem. Please if anybody has solution or cretaed somthing like this please help. Thanks in advance. </p>