title: How to keep the toolbar fixed at the top when AppBar collapses/expands?
body: <h2>Overview</h2>
  <p>I am trying to implement one of the <a href="https://www.google.co.in/design/spec/patterns/scrolling-techniques.html#scrolling-techniques-scrolling" rel="noreferrer">Scrolling Techniques</a>, <em>Flexible space with overlapping content</em>, described in Material Design.</p>
  <blockquote>
  <p><strong>Flexible space with overlapping content</strong></p>
  <p>Content can overlap the app bar.</p>
  <p>Behavior:</p>
  <p>The app bar’s starting position should be located behind the content.
  Upon upward scroll, the app bar should scroll faster than the content,
  until the content no longer overlaps it. Once anchored in place, the
  app bar lifts up to allow content to scroll underneath.</p>
  <p><a href="https://www.google.co.in/design/spec/patterns/scrolling-techniques.html#scrolling-techniques-scrolling" rel="noreferrer">https://www.google.co.in/design/spec/patterns/scrolling-techniques.html#scrolling-techniques-scrolling</a></p>
  </blockquote>
  <hr />
  <h2>Problem</h2>
  <p>However, the problem is,
  the title in my AppBar scrolls down when expanded and hides below the overlapping content.</p>
  <p>Here, my toolbar is hidden below the overlapping CardView.
  <a href="https://i.stack.imgur.com/mSZ18.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mSZ18.png" alt="When appbar expanded" /></a></p>
  <p>When the appbar is collapsed, the toolbar and hence the Title slides up from below.
  <a href="https://i.stack.imgur.com/gFDPQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gFDPQ.png" alt="When collapsed" /></a></p>
  <h2>Code</h2>
  <p>Here's my Code:</p>
  <p>activity-main.xml</p>
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout 
      ...
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;200dp&quot;
          android:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;&gt;
  
          &lt;android.support.design.widget.CollapsingToolbarLayout
              ...
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              app:layout_scrollFlags=&quot;scroll|exitUntilCollapsed&quot;&gt;
  
              &lt;android.support.v7.widget.Toolbar
                  android:id=&quot;@+id/toolbar&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;?attr/actionBarSize&quot;
                  android:layout_gravity=&quot;top&quot;
                  android:background=&quot;?attr/colorPrimary&quot;
                  app:layout_collapseMode=&quot;pin&quot;
                  app:popupTheme=&quot;@style/ThemeOverlay.AppCompat.Light&quot;
                  app:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot; /&gt;
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v4.widget.NestedScrollView
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          ...
  </code></pre>
  <p>I have also added these in my MainActivity's onCreate function</p>
  <pre><code>    setSupportActionBar(toolbar);
  
      collapsingToolbarLayout.setTitle(&quot;App Name&quot;);
  </code></pre>
  <hr />
  <p>I want the toolbar(with the tile and the other contents, which I will add later) to stay at the top irrespective of the appbar being expanded or collapsed.</p>
  <p>I have read the documentations, gone through many posts and tutorials, watched a lot of videos but failed to find a working solution or any related solutions at all.</p>
  <p>If anyone has some idea on how to fix this, please suggest. Thanks for helping.</p>