title: Using custom behaviour to create multiple "anchor points"/positions for CollapsingToolbar
body: <p>I am trying to have a collapsing toolbar that is similar to the Google Maps app in the search landing page. That is, there are three "anchor points" or positions. In place of the map, I will have a picture.</p>
  
  <ul>
  <li>Toolbar collapsed (content is fullscreen)</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/3TGQtm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3TGQtm.png" alt="Fullscreen"></a></p>
  
  <ul>
  <li>Middle position</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/PVeZIm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PVeZIm.png" alt="Half way"></a></p>
  
  <ul>
  <li>Toolbar extended with only some content showing (persistent bottom sheet)</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/rrEelm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rrEelm.png" alt="All the way open"></a></p>
  
  <p>Preferably, the app should <em>snap</em> between these positions.</p>
  
  <p>As of now I have the layout basically working.</p>
  
  <h2>Two main issues are:</h2>
  
  <ul>
  <li>Flinging inside the NestedScrollView does not work correctly. It halts/chops, even though it's using <code>app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"</code>. I believe this is a bug with <code>AppBarLayout</code></li>
  <li>The anchor points described above are not implemented.</li>
  </ul>
  
  <p>This is my layout:</p>
  
  <p>Note that <code>app:layout_behavior="@string/appbar_anchor_behavior"></code> is just an unmodified subclass of <code>AppBarLayout.Behavior</code></p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:id="@+id/main_content"                                                         
   android:layout_width="match_parent"                                               
   android:layout_height="match_parent"                                                           
   android:background="@color/actions_bar_dark"                                                 
   android:fitsSystemWindows="true"&gt;
  
  
  &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/appbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          android:fitsSystemWindows="true"
          app:layout_behavior="@string/appbar_anchor_behavior"&gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
              android:id="@+id/collapsing_toolbar"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:layout_scrollFlags="scroll"
              android:fitsSystemWindows="true"&gt;
  
          &lt;ImageView
                  android:id="@+id/item_preview_thumb"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:scaleType="centerCrop"
                  android:layout_centerInParent="true"
                  app:layout_collapseMode="parallax"
                  /&gt;
  
          &lt;android.support.v7.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                  app:layout_collapseMode="pin" /&gt;
  
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;android.support.v4.widget.NestedScrollView
          android:id="@+id/contentRecyclerView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
  
      &lt;include layout="@layout/item_detail_content"/&gt;
  
  
  &lt;/android.support.v4.widget.NestedScrollView&gt;
  
  &lt;android.support.design.widget.FloatingActionButton
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          app:layout_anchor="@id/appbar"
          app:layout_anchorGravity="bottom|right|end"
          android:src="@drawable/ic_download"
          android:layout_margin="16dp"
          android:clickable="true"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>How can I achieve this using a custom behaviour? </p>