title: Elevation overlay for a standard BottomSheet
body: <p>I'm following the material3 spec, using the <em>android material components</em> lib, and implementing light and dark themes.</p>
  <p>I have a ConstraintLayout acting as a BottomSheet, and its background color should be affected by the <a href="https://m3.material.io/styles/color/the-color-system/color-roles#0abbf8b7-61e1-49ee-9f97-4967beb1e4fe" rel="nofollow noreferrer">elevation overlay</a> tint. BottomSheets are on <a href="https://material.io/develop/android/theming/dark" rel="nofollow noreferrer">the list</a> of material components implementing elevation overlay, but mine is keeping its default color, colorSurface, instead of becoming lighter in dark mode :</p>
  <p><a href="https://i.stack.imgur.com/TBN95.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBN95.jpg" alt="Screenshot" /></a>
  (The color doesn't change when the BottomSheet is expanded.)</p>
  <p>The only thing that defines my ConstraintLayout as a BottomSheet is the <code>layout_behaviour</code> attribute, and I'm wondering how this could actually impact background color. Are BottomSheets only present on the previous list for their <em>modal</em> variant ?</p>
  <p>If so, how would one implement the elevation overlay on a whole ConstraintLayout ? Through an <code>ElevationOverlayProvider</code>, as suggested by the second page linked above ?</p>
  <hr />
  <p>Here is the simplified layout of my main Activity :</p>
  <pre><code>&lt;androidx.coordinatorlayout.widget.CoordinatorLayout
      ...&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          ...&gt;
  
          &lt;com.google.android.material.appbar.MaterialToolbar
              .../&gt;
  
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
      &lt;fragment
          android:id=&quot;@+id/navigation_host_fragment&quot;
          android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
          ... /&gt;
  
      &lt;include
          android:id=&quot;@+id/band_list_bottomsheet&quot;
          layout=&quot;@layout/bottomsheet_filter_and_sort&quot;/&gt;
  
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>
  <p>Here is the included BottomSheet layout (again, simplified) :</p>
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout
      android:id=&quot;@+id/constraint_layout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      app:layout_behavior=&quot;com.google.android.material.bottomsheet.BottomSheetBehavior&quot;
      app:behavior_peekHeight=&quot;?android:attr/listPreferredItemHeight&quot;
      android:fitsSystemWindows=&quot;true&quot;
      android:clickable=&quot;true&quot;
      android:focusable=&quot;true&quot;
      android:elevation=&quot;8dp&quot;
      android:background=&quot;?attr/colorSurface&quot;&gt;
  
      &lt;View
          android:id=&quot;@+id/title_background&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;?android:attr/listPreferredItemHeight&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;/&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/pill&quot;
          android:layout_width=&quot;25dp&quot;
          android:layout_height=&quot;5dp&quot;
          android:layout_marginTop=&quot;8dp&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:srcCompat=&quot;@drawable/bottomsheet_dragable_pill&quot;
          tools:ignore=&quot;ContentDescription&quot;/&gt;
  
      &lt;TextView
          android:id=&quot;@+id/title&quot;
          style=&quot;@style/TextStyle.BottomSheetTitle&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;8dp&quot;
          android:text=&quot;@string/filterandsort_sheet_label&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/pill&quot; /&gt;
  
      &lt;com.google.android.material.divider.MaterialDivider
          android:id=&quot;@+id/divider_title_filter&quot;
          style=&quot;@style/HorizontalDivider&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/title_background&quot;/&gt;
  
      &lt;TextView
          android:id=&quot;@+id/filter_title&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;@string/filter_title&quot;
          style=&quot;@style/TextStyle.BottomSheetSubheader&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/divider_title_filter&quot;/&gt;
          
      ...
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>I've tried a few things on the the ConstraintLayout to trigger the elevation overlay, notably :</p>
  <ul>
  <li>Increase its elevation</li>
  <li>Force its style as the standard BottomSheet style <code>style=&quot;?attr/bottomSheetStyle&quot;</code></li>
  </ul>
  <p>Initially, the ConstaintLayout had no background set, whereas the <code>title_background</code> view had one, a drawable used to display &quot;Google Maps-style&quot; rounded corners at the top of the BottomSheet.</p>
  <p>My themes come from the <a href="https://material-foundation.github.io/material-theme-builder/" rel="nofollow noreferrer">Material Theme Builder</a>, so they extend <code>Theme.Material3.Light.NoActionBar</code> and <code>Theme.Material3.Dark.NoActionBar</code>. As visible above, I'm using system attributes everywhere I can to keep the standard behaviour.</p>