title: Android content height below collapsing toolbar
body: <p>I have an app with a navigation drawer and several fragments. The app has a collapsing toolbar, and the fragments have various content. Some of them are static from XML, others are generated in a recyclerview. Some have a FAB, others don't.</p>
  <p>My problem is whatever layout I have below the toolbar, the container height is calculated from the collapsed state. When I expand the toolbar, I expect the below container to shrink in height, but instead it's just pushed down, and it becomes a problem, when I want to place a FAB into the bottom right corner. This way the FAB is being pushed out of the screen when I expand the toolbar.</p>
  <p><strong>main_activity.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.drawerlayout.widget.DrawerLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/drawer_layout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:fitsSystemWindows=&quot;true&quot;
      tools:openDrawer=&quot;start&quot;&gt;
  
      &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          tools:context=&quot;.MainActivity&quot;&gt;
  
          &lt;com.google.android.material.appbar.AppBarLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;&gt;
  
              &lt;com.google.android.material.appbar.CollapsingToolbarLayout
                  android:id=&quot;@+id/container&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  app:layout_scrollFlags=&quot;scroll|exitUntilCollapsed|snap&quot;&gt;
  
                  &lt;View
                      android:id=&quot;@+id/collapse&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;256dp&quot;
                      app:layout_collapseMode=&quot;parallax&quot; /&gt;
  
                  &lt;com.google.android.material.appbar.MaterialToolbar
                      android:id=&quot;@+id/toolbar&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;?attr/actionBarSize&quot;
                      app:layout_collapseMode=&quot;pin&quot; /&gt;
  
              &lt;/com.google.android.material.appbar.CollapsingToolbarLayout&gt;
  
          &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
          &lt;fragment
              android:id=&quot;@+id/nav_host_fragment&quot;
              android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              app:defaultNavHost=&quot;true&quot;
              app:layout_behavior=&quot;@string/appbar_scrolling_view_behavior&quot;
              app:navGraph=&quot;@navigation/mobile_navigation&quot; /&gt;
  
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  
      &lt;com.google.android.material.navigation.NavigationView
          android:id=&quot;@+id/nav_view&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_gravity=&quot;start&quot;
          android:fitsSystemWindows=&quot;true&quot;
          app:headerLayout=&quot;@layout/drawer_header&quot;
          app:menu=&quot;@menu/drawer&quot; /&gt;
  &lt;/androidx.drawerlayout.widget.DrawerLayout&gt;
  </code></pre>
  <p>So my question is what I should do to force the <code>&lt;fragment&gt;</code> element to fill the remaining place below the appbar and grow or shrink in height instead of partially sliding out of the screen.</p>