title: Show view when toolbar collapses
body: <p>I have an activity with a <code>CoordinatorLayout</code>, <code>AppBarLayout</code>, <code>CollapsingToolbarLayout</code> and <code>Toolbar</code>. So, basically, a view that collapses when scrolling a <code>RecyclerView</code>.</p>
  
  <p>What I need to do is to show a custom view when the view of the expanded layout is hidden due to collapsing.</p>
  
  <p>This is my layout:</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: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="192dp"
          android:fitsSystemWindows="true"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
          &lt;android.support.design.widget.CollapsingToolbarLayout
              android:id="@+id/collapsing_toolbar"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              app:contentScrim="#2196F3"
              app:expandedTitleMarginBottom="32dp"
              app:expandedTitleMarginEnd="64dp"
              app:expandedTitleMarginStart="48dp"
              app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
  
              &lt;include
                  android:id="@+id/header"
                  layout="@layout/header_big_first_screen"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fitsSystemWindows="true"
                  android:scaleType="centerCrop"
                  app:layout_collapseMode="parallax"/&gt;
  
              &lt;android.support.v7.widget.CollapsingToolbarLayout
                  android:id="@+id/anim_toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:layout_collapseMode="pin"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;
  
                  &lt;TextView
  
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:text="Hello!"/&gt;
  
  
              &lt;/android.support.v7.widget.CollapsingToolbarLayout&gt;
  
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/categories_recyclerview"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>In the end, when the toolbar is expanded the view loaded with the  element is shown. When it is collapsed it doesn't . When it disappears the <code>TextView</code> inside <code>Toolbar</code>should be shown. Currently it shows all the time.</p>
  
  <p>I've been looking in the events of <code>CollapsingToolbarLayout</code> to add a listener when it changes size so I can check if that is smaller than a value and show that view.</p>
  
  <p>This can be kind of tricky to explain but I believe I made myself clear. I've been googling around and cannot find anyone trying to do the same.</p>