title: CollapsingToolBarLayout with TabLayout and ViewPager
body: <p><a href="https://i.stack.imgur.com/0XkZK.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/0XkZK.jpg" alt="Layout example from app"></a></p>
  
  <p>Am try to create a layout similar to the one in the image using a CordinatorLayout and CollapsingToolbarLayout, TabLayout and ViewPager.
  My Layout doesn't render properly.</p>
  
  <p>Here is my layout</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: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:background="?attr/colorPrimary"
          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"
              app:contentScrim="?attr/colorPrimary"
              app:expandedTitleMarginStart="48dp"
              app:expandedTitleMarginEnd="64dp"
              android:fitsSystemWindows="true"&gt;
  
              &lt;ImageView
                  android:id="@+id/image"
                  android:src="@drawable/thumb_placeholder"
                  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"
                  android:background="?attr/colorPrimary"
                  app:layout_collapseMode="pin" /&gt;
  
              &lt;android.support.design.widget.TabLayout
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:app="http://schemas.android.com/apk/res-auto"
                  android:id="@+id/movie_tabs"
                  app:tabGravity="fill"
                  app:tabMode="fixed"
                  android:background="@color/colorPrimary"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  app:tabTextColor="@color/textColorPrimary"
                  app:tabSelectedTextColor="@color/textColorPrimary"
                  app:tabIndicatorColor="@color/textColorPrimary"
                  app:tabIndicatorHeight="4dp"
                  app:paddingStart="20dp"
                  app:paddingEnd="20dp"&gt;
              &lt;/android.support.design.widget.TabLayout&gt;
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/movieviewpager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
      &lt;/android.support.v4.view.ViewPager&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>Testing it on my device i get this
  <a href="https://i.stack.imgur.com/XokNq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XokNq.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/0VQBq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0VQBq.png" alt="enter image description here"></a></p>
  
  <p>The ViewPager Fragment overlays the TabLayout if it has content and displays the TabLayout on top of the ImageView when there is no content.
  What am i doing wrong, i am still somewhat of an Android noob.</p>