title: Need to collapse/expand part of appbar on button click
body: <p>I got a <a href="https://i.stack.imgur.com/uivbW.png" rel="nofollow noreferrer">layout</a> where i need to expand/collapse the part of appbarlayout on click of button in a toolbar.
  I know how to do all the stuff, except the hide/show itself. I tried to use <code>AppBarLayout.setExpanded(false)</code> but its not working.
  Here is my XML</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="com.softdeal.gazdaifua.activity.MainActivity"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"
      android:id="@+id/main_appbar"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:layout_gravity="fill"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay"
          android:layout_weight="1"&gt;
  
          &lt;ImageButton
              android:id="@+id/btn_filter"
              android:layout_width="48dp"
              android:layout_height="48dp"
              android:layout_gravity="end"
              android:background="?selectableItemBackgroundBorderless"
              app:srcCompat="@drawable/ic_filter_list_white_48dp" /&gt;
  
      &lt;/android.support.v7.widget.Toolbar&gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/main.collapsing"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"&gt;
  
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              app:layout_collapseMode="pin"&gt;
  
              &lt;EditText
                  android:id="@+id/editText"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:inputType="number" /&gt;
  
              &lt;Spinner
                  android:id="@+id/spinner"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" /&gt;
  
              &lt;Spinner
                  android:id="@+id/spinner1"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" /&gt;
          &lt;/LinearLayout&gt;
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;include layout="@layout/content_main" /&gt;
  
  &lt;android.support.design.widget.FloatingActionButton
      android:id="@+id/fab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|end"
      android:layout_margin="@dimen/fab_margin"
      android:visibility="invisible"
      app:srcCompat="@drawable/ic_add_plus_button" /&gt;
  </code></pre>