title: Android: Collapsing Linearlayout instead of Collapsing Toolbar
body: <p>I'm trying to create a Master/Detail transaction in a single fragment. I thought of using LinearLayout as the container of my edittext for my header. Then a RecyclerView for details.</p>
  
  <p>How would one implement the collapsing/expanding of LinearLayout similar to that of the CollapsingToolbar effect?</p>
  
  <p>Here's a screenshot of what I'm trying to do.</p>
  
  <p><a href="https://i.stack.imgur.com/l09kz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l09kz.png" alt="enter image description here"></a></p>
  
  <p>My xml code so far.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout 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:orientation="vertical"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:background="@color/colorAccent"
          android:padding="@dimen/activity_horizontal_margin"&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"&gt;
  
              &lt;ImageView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:src="@drawable/ic_date_range_black_24dp"
                  android:tint="@android:color/darker_gray" /&gt;
  
              &lt;android.support.v4.widget.Space
                  android:layout_width="@dimen/activity_horizontal_margin"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;android.support.design.widget.TextInputLayout
                  android:id="@+id/date_til"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:hint="Date"&gt;
  
                  &lt;android.support.design.widget.TextInputEditText
                      android:id="@+id/date"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:cursorVisible="false"
                      android:focusable="false"
                      android:longClickable="false" /&gt;
  
              &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"&gt;
  
              &lt;ImageView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:src="@drawable/ic_store_black_24dp"
                  android:tint="@android:color/darker_gray" /&gt;
  
              &lt;android.support.v4.widget.Space
                  android:layout_width="@dimen/activity_horizontal_margin"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;android.support.design.widget.TextInputLayout
                  android:id="@+id/store_til"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:hint="Store"&gt;
  
                  &lt;android.support.design.widget.TextInputEditText
                      android:id="@+id/store"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content" /&gt;
  
              &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"&gt;
  
              &lt;ImageView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:src="@drawable/ic_place_black_24dp"
                  android:tint="@android:color/darker_gray" /&gt;
  
              &lt;android.support.v4.widget.Space
                  android:layout_width="@dimen/activity_horizontal_margin"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;android.support.design.widget.TextInputLayout
                  android:id="@+id/location_til"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
                  &lt;android.support.design.widget.TextInputEditText
                      android:id="@+id/location"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:hint="Location" /&gt;
  
              &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/recycler"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scrollbars="vertical"
          app:layoutManager="LinearLayoutManager"
          tools:listitem="@layout/list_car" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Also, not sure if this can be done with the CollapsingToolbar since I've mostly seen only ImageView collapsing in the Toolbar.</p>
  
  <p>Appreaciate any help.</p>
  
  <p>UPDATE: Basically what I want to do here is to be able to collapse the header view when scrolling up. Then expand when scrolling down.</p>