title: Stop Scrolling for CollapsingToolbarLayout when showing a Fragment
body: <p>I have a <code>ViewPager</code> inside an <code>Activity</code> which shows two <code>Fragments</code>. </p>
  
  <p>The activity has a <code>TabLayout</code> and a <code>CollapsingToolbarLayout</code>. The <code>CollapsingToolbarLayout</code> is nested inside the <code>AppBarLayout</code> with an <code>ImageView</code> to produce a parallax effect. The <code>TabLayout</code> is outside the <code>AppBarLayout</code> inside a <code>LinearLayout</code> with the <code>ViewPager</code>. Then there is a <code>FrameLayout</code> as well to show another <code>Fragment</code> over the <code>ViewPager</code> when the user clicks a button to show that <code>Fragment</code>.</p>
  
  <p>The problem is that when you scroll the <code>RecyclerView</code> inside the <code>Fragment</code> that overlays on top of the <code>ViewPager</code> the <code>Activity</code> also scrolls and does the parallax effect. Essentially it scrolls both the <code>RecyclerView</code> inside the <code>Fragment</code> and the content inside the <code>ViewPager</code> as well.</p>
  
  <p>Is there a way to stop scrolling for the <code>CollapsingToolbarLayout</code> and only scroll content in the overlay <code>Fragment</code> when the user sees that <code>Fragment</code>? </p>
  
  <p>This is what my XML Hierarchy looks like:</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout&gt;
  
  &lt;android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
          app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
  
          &lt;ImageView
              app:layout_collapseMode="parallax"/&gt;
  
          &lt;android.support.v7.widget.Toolbar /&gt;
  
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;LinearLayout
      app:layout_behavior="@string/appbar_scrolling_view_behavior" &gt;
  
      &lt;android.support.design.widget.TabLayout /&gt;
      &lt;!-- Two fragments inside ViewPager each containing a RecyclerView --&gt;
      &lt;android.support.v4.view.ViewPager /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;!-- User Clicks a button and fragment is added to this framelayout --&gt;
  &lt;!-- This fragment overlays on top of the entire Activity layout --&gt;
  &lt;!-- This fragment also contains a recyclerview --&gt;
  &lt;FrameLayout/&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>