Skip to content

Commit aaa40db

Browse files
Material Design Teampekingme
authored andcommitted
Automated g4 rollback of changelist 754982643
PiperOrigin-RevId: 755433180
1 parent 43bcfbd commit aaa40db

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

docs/components/BottomSheet.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -562,26 +562,31 @@ bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallback)
562562
<details>
563563
<summary><h3>Handling insets and fullscreen</h3></summary>
564564

565-
`BottomSheetBehavior` automatically handles window insets by applying padding to
566-
the top and bottom of the view and margins to the left and right. These
567-
paddings and margins can be customized by specifying any of the following
568-
attributes on the view:
565+
`BottomSheetBehavior` can automatically handle insets (such as for
566+
[edge to edge](https://developer.android.com/training/gestures/edge-to-edge)) by
567+
specifying any of these to true on the view:
569568

570569
* `app:paddingBottomSystemWindowInsets`
571570
* `app:paddingLeftSystemWindowInsets`
572571
* `app:paddingRightSystemWindowInsets`
573572
* `app:paddingTopSystemWindowInsets`
574573

575-
* `app:marginLeftSystemWindowInsets`
576-
* `app:marginRightSystemWindowInsets`
577-
* `app:marginTopSystemWindowInsets`
574+
On API 21 and above the modal bottom sheet will be rendered fullscreen (edge to
575+
edge) if the navigation bar is transparent and `enableEdgeToEdge` is true.
576+
To enable edge-to-edge by default for modal bottom sheets, you can override
577+
`?attr/bottomSheetDialogTheme` like the below example (`enableEdgeToEdge` is
578+
already true in `ThemeOverlay.Material3.BottomSheetDialog`):
578579

579-
Modal bottom sheets are rendered fullscreen by default. On API 21-34, this can
580-
be overriden by setting `enableEdgeToEdge` to `false` in your
581-
`?attr/bottomSheetDialogTheme` ThemeOverlay. On API 35 and above,
582-
`enableEdgeToEdge` has been deprecated and will no longer take effect. To
583-
learn more, read about [edge-to-edge enforcement on Android 15](https://developer.android.com/about/versions/15/behavior-changes-15#edge-to-edge).
580+
```xml
581+
<style name="AppTheme" parent="Theme.Material3.*">
582+
...
583+
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.App.BottomSheetDialog</item>
584+
</style>
584585

586+
<style name="ThemeOverlay.App.BottomSheetDialog" parent="ThemeOverlay.Material3.BottomSheetDialog">
587+
<item name="android:navigationBarColor">@android:color/transparent<item>
588+
</style>
589+
```
585590
Insets can be added automatically if any of the padding attributes above are set
586591
to true in the style, either by updating the style passed to the constructor, or
587592
by updating the default style specified by the `?attr/bottomSheetDialogTheme`

lib/java/com/google/android/material/bottomsheet/BottomSheetDialog.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,12 @@ protected BottomSheetDialog(
110110
}
111111

112112
private void initialize() {
113-
if (VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM) {
114-
edgeToEdgeEnabled = true;
115-
return;
116-
}
117-
118113
final TypedArray a = getContext()
119114
.getTheme()
120115
.obtainStyledAttributes(new int[] {R.attr.enableEdgeToEdge});
116+
121117
edgeToEdgeEnabled = a.getBoolean(0, false);
118+
122119
a.recycle();
123120
}
124121

@@ -132,10 +129,8 @@ protected void onCreate(Bundle savedInstanceState) {
132129
super.onCreate(savedInstanceState);
133130
Window window = getWindow();
134131
if (window != null) {
135-
if (VERSION.SDK_INT < VERSION_CODES.VANILLA_ICE_CREAM) {
136-
// The status bar should always be transparent because of the window animation.
137-
window.setStatusBarColor(0);
138-
}
132+
// The status bar should always be transparent because of the window animation.
133+
window.setStatusBarColor(0);
139134

140135
window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
141136
if (VERSION.SDK_INT < VERSION_CODES.M) {
@@ -185,7 +180,9 @@ public void onAttachedToWindow() {
185180
super.onAttachedToWindow();
186181
Window window = getWindow();
187182
if (window != null) {
188-
boolean drawEdgeToEdge = shouldDrawEdgeToEdge(window);
183+
// If the navigation bar is transparent at all the BottomSheet should be edge to edge.
184+
boolean drawEdgeToEdge =
185+
edgeToEdgeEnabled && Color.alpha(window.getNavigationBarColor()) < 255;
189186
if (container != null) {
190187
container.setFitsSystemWindows(!drawEdgeToEdge);
191188
}
@@ -202,14 +199,6 @@ public void onAttachedToWindow() {
202199
updateListeningForBackCallbacks();
203200
}
204201

205-
private boolean shouldDrawEdgeToEdge(Window window) {
206-
if (VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM) {
207-
return true;
208-
}
209-
210-
return edgeToEdgeEnabled && Color.alpha(window.getNavigationBarColor()) < 255;
211-
}
212-
213202
@Override
214203
public void onDetachedFromWindow() {
215204
if (edgeToEdgeCallback != null) {

lib/java/com/google/android/material/bottomsheet/res/values/attrs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<!-- Style to use for modal bottom sheets in this theme. -->
2222
<attr name="bottomSheetStyle" format="reference"/>
2323
<!-- Determines if the BottomSheetDialog should be shown in edge to edge mode. -->
24-
<!-- Deprecated. Edge to Edge is always enabled on API 35 and above. -->
2524
<attr name="enableEdgeToEdge" format="boolean" />
2625
<!-- Style of drag handle views when being used with bottom sheets. -->
2726
<attr name="bottomSheetDragHandleStyle" format="reference"/>

0 commit comments

Comments
 (0)