title: How to Pin toolbar in a coordinator layout using collapsing toolbar?
body: <p>I am trying to make the toolbar appear in this layout always visible instead of it appearing only when it is scrolled out completely. I have an image inside collapsing toolbar that needs to get hidden when scrolled out fully.</p>
  
  <p>This is what I tried.. Any opinion on how to achieve it?</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"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          tools:context=".activities.Event_details"&gt;
  
  
      &lt;RelativeLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/topLayout"
          app:layout_anchorGravity="top"
          android:layout_gravity="top" &gt;
          &lt;android.support.v7.widget.Toolbar
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:id="@+id/toolbar"
              app:layout_collapseMode="pin"
              app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;
              &lt;RelativeLayout
                  android:layout_width="match_parent"
                  android:layout_height="@dimen/toolbar_height"&gt;
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textColor="@color/colorWhite"
                      android:id="@+id/toolbarTitle"
                      android:layout_centerVertical="true"
                      android:layout_marginEnd="?android:attr/actionBarSize"
                      android:textStyle="bold"
                      android:textSize="@dimen/page_innerheader_titletxt"
                      android:text="@string/app_name"/&gt;
  
                  &lt;TextView
                      android:id="@+id/save_toolbar"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="@string/save"
                      android:textColor="@color/colorYellow"
                      android:layout_centerVertical="true"
                      android:textSize="@dimen/textsize16"
                      android:layout_toStartOf="@id/toolbarButton"
                      android:layout_marginEnd="15dp"/&gt;
  
                  &lt;Button
                      android:id="@+id/toolbarButton"
                      android:layout_width="60dp"
                      android:layout_height="30dp"
                      android:text="@string/done"
                      android:layout_alignParentEnd="true"
                      android:layout_centerVertical="true"
                      android:textColor="@color/colorPrimary"
                      android:background="@drawable/rect_yellow"
                      android:layout_marginEnd="10dp"
                      /&gt;
              &lt;/RelativeLayout&gt;
  
  
          &lt;/android.support.v7.widget.Toolbar&gt;
  
             &lt;/RelativeLayout&gt;
          &lt;android.support.design.widget.AppBarLayout
              android:id="@+id/app_bar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:elevation="6dp"
              app:layout_anchor="@id/topLayout"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              android:fitsSystemWindows="true"&gt;
  
  
              &lt;android.support.design.widget.CollapsingToolbarLayout
                  android:id="@+id/toolbar_layout"
                  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:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="@drawable/party"
                      android:fitsSystemWindows="true"
                      android:scaleType="centerCrop"
                      app:layout_collapseMode="parallax"/&gt;
  
  &lt;!--
  
              &lt;android.support.v7.widget.Toolbar
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  android:id="@+id/toolbar"
                  app:layout_collapseMode="pin"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;
                  &lt;RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="@dimen/toolbar_height"&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textColor="@color/colorWhite"
                          android:id="@+id/toolbarTitle"
                          android:layout_centerVertical="true"
                          android:layout_marginEnd="?android:attr/actionBarSize"
                          android:textStyle="bold"
                          android:textSize="@dimen/page_innerheader_titletxt"
                          android:text="@string/app_name"/&gt;
  
                      &lt;TextView
                          android:id="@+id/save_toolbar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="@string/save"
                          android:textColor="@color/colorYellow"
                          android:layout_centerVertical="true"
                          android:textSize="@dimen/textsize16"
                          android:layout_toStartOf="@id/toolbarButton"
                          android:layout_marginEnd="15dp"/&gt;
  
                      &lt;Button
                          android:id="@+id/toolbarButton"
                          android:layout_width="60dp"
                          android:layout_height="30dp"
                          android:text="@string/done"
                          android:layout_alignParentEnd="true"
                          android:layout_centerVertical="true"
                          android:textColor="@color/colorPrimary"
                          android:background="@drawable/rect_yellow"
                          android:layout_marginEnd="10dp"
                          /&gt;
                  &lt;/RelativeLayout&gt;
  
  
              &lt;/android.support.v7.widget.Toolbar&gt;
  --&gt;
  
  
              &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
          &lt;/android.support.design.widget.AppBarLayout&gt;
  
  
          &lt;include layout="@layout/content_main_eventdetails" /&gt;
  
      &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>P.S: I also tried using the toolbar inside the collapsing toolbar but I can make only the title and button visible but I want the whole toolbar to have a <code>colorPrimary</code> background.</p>
  
  <p>I tried these links <a href="https://stackoverflow.com/questions/32064046/how-to-keep-the-toolbar-fixed-at-the-top-when-appbar-collapses-expands">collapsing toolbar fixed</a> and this <a href="https://medium.com/@tonia.tkachuk/appbarlayout-scroll-behavior-with-layout-scrollflags-2eec41b4366b" rel="nofollow noreferrer">AppBar layout behaviour</a> and some from the other SO threads. But nothing seems to solve my problem.</p>