title: dynamically set height of view behind BottomSheet to fill space above sheet
body: <p>I'm trying to correctly set the height of the view (mapfragment in below example) that normally sits behind the BottomSheet. </p>
  
  <p>I want the bottom sheet to persist in a half-open state with the option to expand to full screen, but not fully collapse. Example of desired functionality on the two right screens of these <a href="https://i.stack.imgur.com/VZ51O.png" rel="nofollow noreferrer">uber examples</a>. To do this I set the peek height to half the screen width  and the mapfragment height to half and that kinda worked</p>
  
  <pre><code>        // Get bottom nav height
          var navBarHeight = 0
          val navBarId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
          if (navBarId &gt; 0) {
              navBarHeight = convertDpToPixel(resources.getDimensionPixelSize(navBarId))
          }
          // Set bottom sheet "persisted" open height
          val metrics = resources.displayMetrics
          bottomSheetBehavior.peekHeight = metrics.heightPixels / 2
  
          // programmatically set map height
          val params = mapFragment?.view?.layoutParams
          params?.height = (metrics.heightPixels / 2) - navBarHeight
          mapFragment?.view?.layoutParams = params
  
  </code></pre>
  
  <p>However, there's an issue as shown in this screenshot - <a href="https://i.stack.imgur.com/OIfEr.jpg" rel="nofollow noreferrer">fragment height mismatch</a> - where the "Google" logo and "locate me" button on the map are slightly covered due to some insets not being accounted for.</p>
  
  <p>I'm assuming I have to dynamically account for the insets and bottom nav to get the correct height. This just seems rather error prone though considering the varying sizes of those across devices and versions. I have to imagine there's a better way, no?</p>
  
  <p>Due to limitations of the BottomSheet component, I can't wrap the <code>FrameLayout</code> in a <code>LinearLayout</code> and use a <code>layout_weight</code> solution as it needs to be a direct child of the <code>CoordinatorLayout</code>.</p>
  
  <pre><code>    &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;!-- I want both of these fragments to fill 50% of this coordinator layout --&gt; 
          &lt;fragment
              android:id="@+id/mapFragment"
              android:name="com.google.android.gms.maps.SupportMapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
  
          &lt;FrameLayout
              android:id="@+id/standardBottomSheet"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"&gt;
  
              &lt;!--...  bottom screen layout ... --&gt;
  
  
          &lt;/FrameLayout&gt;
  
  
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  
  </code></pre>
  
  <p>Is there something I'm missing here?</p>