title: RecyclerView and ViewPager with collapsing toolbar
body: <p>I am trying to create this kind of a layout where -</p>
  
  <ol>
  <li>A <code>CollapsingToolbarLayout</code> that has a <code>ViewPager</code> like google play app.</li>
  <li>Below that there is a Grid <code>RecyclerView</code>.</li>
  <li>And at the end, there is another <code>ViewPager</code>.</li>
  </ol>
  
  <p>The <code>RecylerView</code> scrolls normally until the end when <code>CollapsingToolbarLayout</code> expands.</p>
  
  <p><a href="https://i.stack.imgur.com/pRu4I.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pRu4I.jpg" alt="enter image description here"></a> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.design.widget.CoordinatorLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"&gt;
  
          &lt;android.support.design.widget.AppBarLayout
              android:id="@+id/app_bar_layout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:fitsSystemWindows="true"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
              &lt;android.support.design.widget.CollapsingToolbarLayout
                  android:id="@+id/collapsing_toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fitsSystemWindows="true"
                  app:contentScrim="?attr/colorPrimary"
                  app:expandedTitleMarginEnd="64dp"
                  app:expandedTitleMarginStart="48dp"
                  app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:fitsSystemWindows="true"
                      android:orientation="vertical"
                      app:layout_collapseMode="parallax"&gt;
  
                      &lt;TextView
                          android:id="@+id/text_home_active"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:layout_margin="@dimen/margin_normal"
                          android:background="@color/header_bg"
                          android:gravity="center_vertical"
                          android:textColor="@android:color/black"
                          android:textSize="@dimen/title_date_text_size" /&gt;
  
                      &lt;android.support.v4.view.ViewPager
                          android:id="@+id/viewpager_home"
                          android:layout_width="fill_parent"
                          android:layout_height="170dp"
                          android:layout_gravity="center"
                          android:overScrollMode="ifContentScrolls" /&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;android.support.v7.widget.Toolbar
                      android:id="@+id/toolbar"
                      android:layout_width="match_parent"
                      android:layout_height="?attr/actionBarSize"
                      android:background="@color/color_primary"
                      android:minHeight="?attr/actionBarSize"
                      app:layout_collapseMode="pin"
                      app:theme="@style/ToolBarStyle" /&gt;
  
              &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
          &lt;/android.support.design.widget.AppBarLayout&gt;
  
          &lt;android.support.v4.widget.NestedScrollView
              android:id="@+id/scroll"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clipToPadding="false"
              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"
                  android:weightSum="3"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="0dp"
                      android:layout_weight="2"
                      android:orientation="vertical"&gt;
  
                      &lt;TextView
                          android:id="@+id/text_home_popular"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@color/header_bg"
                          android:gravity="center_vertical"
                          android:padding="@dimen/margin_normal"
                          android:textColor="@android:color/black"
                          android:textSize="@dimen/title_date_text_size" /&gt;
  
                      &lt;android.support.v7.widget.RecyclerView
                          android:id="@+id/grid_home_popular"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:clipToPadding="false"
                          android:scrollbars="none"
                          app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;
  
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="0dp"
                      android:layout_gravity="bottom"
                      android:layout_weight="1"
                      android:elevation="5dp"
                      android:orientation="vertical"&gt;
  
                      &lt;TextView
                          android:id="@+id/text_home_offers"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:layout_margin="@dimen/margin_normal"
                          android:gravity="center_vertical"
                          android:text="@string/text_home_offers"
                          android:textColor="@android:color/black"
                          android:textSize="@dimen/title_date_text_size" /&gt;
  
                      &lt;android.support.v4.view.ViewPager
                          android:id="@+id/viewpager_home_offers"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          android:overScrollMode="ifContentScrolls" /&gt;
                  &lt;/LinearLayout&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/android.support.v4.widget.NestedScrollView&gt;
      &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/recyclerViewNavigation"
          android:layout_width="300dp"
          android:layout_height="match_parent"
          android:layout_gravity="left"
          android:background="#ffffff"
          android:scrollbars="none" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>My problem is toolbar collapse only when I move outside the RecyclerView.</p>