Skip to content

Commit b3f32d4

Browse files
committed
[TopAppBar] Added app:layout_scrollEffect to public attributes.
PiperOrigin-RevId: 509484463
1 parent bdf73bf commit b3f32d4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docs/components/TopAppBar.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,34 @@ In the layout:
266266
</androidx.coordinatorlayout.widget.CoordinatorLayout>
267267
```
268268

269+
Optionally, you can change the style in which the app bar disappears and
270+
appears when scrolling by setting a scroll effect. By default, a scroll effect
271+
of `none` is set which translates the app bar in-step with the scrolling
272+
content. The following option shows setting the `compress` scroll effect
273+
which clips the top app bar until it meets the top of the screen:
274+
275+
In the layout:
276+
277+
```xml
278+
<androidx.coordinatorlayout.widget.CoordinatorLayout
279+
...>
280+
281+
<com.google.android.material.appbar.AppBarLayout
282+
...>
283+
284+
<com.google.android.material.appbar.MaterialToolbar
285+
...
286+
app:layout_scrollFlags="scroll|enterAlways|snap"
287+
app:layout_scrollEffect="compress"
288+
/>
289+
290+
</com.google.android.material.appbar.AppBarLayout>
291+
292+
...
293+
294+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
295+
```
296+
269297
### Status bar and edge-to-edge
270298

271299
![Small top app bar with edge-to-edge status bar](assets/topappbar/topappbar_small.png)
@@ -375,6 +403,7 @@ Element | Attribute
375403
**`AppBarLayout` lift on scroll** | `app:liftOnScroll` | `setLiftOnScroll`<br>`isLiftOnScroll` | `true`
376404
**`AppBarLayout` lift on scroll color** | `app:liftOnScrollColor` | N/A | `@null` (defaults to elevation overlay color)
377405
**`AppBarLayout` lift on scroll target view** | `app:liftOnScrollTargetViewId` | `setLiftOnScrollTargetViewId`<br>`getLiftOnScrollTargetViewId` | `@null`
406+
**`AppBarLayout` scroll effect** | `app:layout_scrollEffect` | `setScrollEffect`<br>`getScrollEffect` | `none`
378407

379408
#### `AppBarLayout` styles
380409

lib/java/com/google/android/material/appbar/res-public/values/public.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<public name="collapsingToolbarLayoutLargeSize" type="attr"/>
2424
<public name="toolbarSurfaceStyle" type="attr"/>
2525
<public name="layout_scrollInterpolator" type="attr"/>
26+
<public name="layout_scrollEffect" type="attr"/>
2627
<public name="behavior_overlapTop" type="attr"/>
2728
<public name="expandedTitleMargin" type="attr"/>
2829
<public name="expandedTitleMarginStart" type="attr"/>

0 commit comments

Comments
 (0)