title: Scrolling with Collapsing Toolbar and Tabs
body: <p>I'm trying to make a layout with a <code>CollapsingToolbarLayout</code> which has <code>scroll|exitUntilCollapsed</code> flag, and a <code>TabLayout</code> which has <code>scroll|enterAlways</code> scrollFlag property. Basically I want my toolbar to be pinned and show and hide the tabs while scrolling. I've modified the cheesesquare app from <a href="https://github.com/chrisbanes/cheesesquare" rel="noreferrer">https://github.com/chrisbanes/cheesesquare</a>. Here is my layout xml;</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &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:fitsSystemWindows="true"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/appbar"
          android:layout_width="match_parent"
          android:layout_height="@dimen/detail_backdrop_height"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          android:fitsSystemWindows="true"&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|exitUntilCollapsed"
              android:fitsSystemWindows="true"
              app:contentScrim="?attr/colorPrimary"
              app:expandedTitleMarginStart="48dp"
              app:expandedTitleMarginEnd="64dp"&gt;
  
              &lt;ImageView
                  android:id="@+id/backdrop"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:scaleType="centerCrop"
                  android:fitsSystemWindows="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.TabLayout
                  android:id="@+id/tabs"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  app:layout_scrollFlags="scroll|enterAlways"
                  app:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt;
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/viewpager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior" /&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_discuss"
          android:layout_margin="@dimen/fab_margin"
          android:clickable="true"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>And here is the result;</p>
  
  <p>The tabs are not positioned properly. And they don't care about the enterAlways property.</p>
  
  <p><a href="https://i.stack.imgur.com/RjDJn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RjDJn.png" alt="enter image description here"></a></p>