title: CoordinatorLayout with RecyclerView
body: <p>I have a LinearLayout that I want to hide when I scroll up on my RecyclerView, and reappear when I scroll down; the behaviour should be just like how the Toolbar hides and reappears.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
     &lt;LinearLayout
          android:id="@+id/viewToHideOnScroll
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;!-- other stuff inside the LinearLayout --&gt;
  
     &lt;/LinearLayout&gt;
  
     &lt;RecyclerView
          android:id="@+id/recyclerView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>From what I can understand so far, I can specify a <code>app:layout_behavior</code> value on <code>viewToHideOnScroll</code> so that it smooth scrolls in and out of view according to scroll events on <code>recyclerView</code>. To do this, I have to write a custom class <code>ViewToHideOnScrollBehavior</code> and override <code>layoutDependsOn</code> and some other method (<code>onNestedScroll</code>?). </p>
  
  <p>If that is correct, here is what I have:</p>
  
  <pre><code>public class ViewToHideOnScrollBehavior extends CoordinatorLayout.Behavior&lt;LinearLayout&gt; {
  
  public ViewToHideOnScrollBehavior(Context context, AttributeSet attrs) {}
  
      @Override
      public boolean layoutDependsOn(CoordinatorLayout parent, LinearLayout child, View dependency) {
          return dependency instanceof RecyclerView;
      }
  
      // some other method to override, I don't know
  }
  </code></pre>
  
  <p>Can someone give me a hint, or am I doing this all wrong?</p>
  
  <p>I've been following <a href="https://lab.getbase.com/introduction-to-coordinator-layout-on-android/" rel="noreferrer">https://lab.getbase.com/introduction-to-coordinator-layout-on-android/</a></p>