title: Android Toolbar show/hide blank space
body: <p>I'm trying to have my toolbar hide or show when the user is scrolling a list. To do it, I'm using a translation but a blank space appears instead of my actionBar. If I use a setVisibility(View.GONE), the blank space will appear during the animation and hide when it's done which is ugly..</p>
  
  <p><a href="https://www.youtube.com/watch?v=_afm_-4pcbA&amp;feature=youtu.be">Here is a short video of my issue</a></p>
  
  <p>And here is how i do my animation (from Google I/O app) :</p>
  
  <pre><code>public void showToolbar(boolean show){
      if (show) {
          toolbar.animate()
                  .translationY(0)
                  .alpha(1)
                  .setDuration(HEADER_HIDE_ANIM_DURATION)
                  .setInterpolator(new DecelerateInterpolator());
      } else {
          toolbar.animate()
                  .translationY(-toolbar.getBottom())
                  .alpha(0)
                  .setDuration(HEADER_HIDE_ANIM_DURATION)
                  .setInterpolator(new DecelerateInterpolator());
      }
  }
  </code></pre>
  
  <p>And here is my layout :</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/mainContent"&gt;
  
  &lt;include layout="@layout/toolbar"
      android:id="@+id/my_toolbar" /&gt;
  
  &lt;fragment
      android:name="com.ar.oe.fragments.SectionsFragment"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginTop="?attr/actionBarSize"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And my toolbar</p>
  
  <pre><code>&lt;android.support.v7.widget.Toolbar
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/my_toolbar"
  android:layout_height="?attr/actionBarSize"
  android:layout_width="match_parent"
  android:minHeight="?attr/actionBarSize"
  android:background="?attr/colorPrimary"
  /&gt;
  </code></pre>