Skip to content

Commit 32f41ff

Browse files
hunterstichdrchen
authored andcommitted
[TopAppBar] Added documentation for status bar foreground on scrolling app bars.
PiperOrigin-RevId: 464788174
1 parent eca825f commit 32f41ff

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

docs/components/TopAppBar.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ Make sure to set `android:fitsSystemWindows="true"` on your `AppBarLayout` (or
281281
`MaterialToolbar` if not using `AppBarLayout`), so that an extra inset is added
282282
to avoid overlap with the status bar.
283283

284+
If your `AppBarLayout` scrolls and content is visible under the status bar, you
285+
can set the `AppBarLayout`'s `statusBarForeground` to a `MaterialShapeDrawable`
286+
to let `AppBarLayout` automatically match the status bar color to its own
287+
background.
288+
289+
In code:
290+
291+
```
292+
appBarLayout.setStatusBarForeground(
293+
MaterialShapeDrawable.createWithElevationOverlay(getContext()));
294+
```
295+
284296
### Center aligned top app bar example
285297

286298
All of the same guidance and code from the sections above is relevant for Center

0 commit comments

Comments
 (0)