Skip to content

Commit b4e08ad

Browse files
Material Design Teamdsn5ft
authored andcommitted
[Docs] Updated Floating Toolbar doc to make it more user friendly
PiperOrigin-RevId: 787618839
1 parent e05d3ee commit b4e08ad

File tree

2 files changed

+107
-77
lines changed

2 files changed

+107
-77
lines changed

docs/components/FloatingToolbar.md

Lines changed: 107 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,99 @@
11
<!--docs:
2-
title: "Floating Toolbar"
2+
title: "Floating toolbar"
33
layout: detail
44
section: components
55
excerpt: "Floating toolbars show actions related to the current page"
66
iconId: floating_toolbar
77
path: /catalog/floating-toolbar/
88
-->
99

10-
# Floating Toolbar
10+
# Floating toolbar
1111

12-
Floating Toolbar provides a way to show actions related to the current page.
13-
Floating Toolbar is an undocked variant of Toolbars.
12+
Floating toolbar provides a way to show actions related to the current page.
13+
Floating toolbars can be vertical or horizontal.
1414

15-
See [Top App Bars](TopAppBar.md) and [Bottom App Bars](BottomAppBar.md) for docked Toolbar variants.
15+
Vertical floating toolbar | Horizontal floating toolbar
16+
:----------------------------------------------------------------------------------------------: | :-------------------------:
17+
<img src="assets/floatingtoolbar/ftbvertical.png" alt="Vertical floating toolbar" height="500"/> | <img src="assets/floatingtoolbar/ftbhorizontal.png" alt="Horizontal floating toolbar" width="590"/>
1618

17-
Floating toolbars can be vertical or horizontal.
19+
**Note:** Images use various dynamic color schemes.
20+
21+
## Design & API documentation
22+
23+
* [Material 3 (M3) spec](https://m3.material.io/components/toolbars/overview)
24+
* API reference in progress
25+
26+
## Anatomy
27+
28+
<img src="assets/floatingtoolbar/ftbanatomy.png" alt="Floating toolbar anatomy diagram" width="600"/>
29+
30+
1. Container
31+
2. Elements
32+
33+
More details on anatomy items in the
34+
[component guidelines](https://m3.material.io/components/toolbars/guidelines#d6b7bcb1-295d-41e6-a051-37f12e1c96ab).
35+
36+
## M3 Expressive update
37+
38+
Before you can use `Material3Expressive` component styles, follow the
39+
[`Material3Expressive themes` setup instructions](https://github.com/material-components/material-components-android/tree/master/docs/getting-started.md#material3expressive-themes).
40+
41+
<img src="assets/floatingtoolbar/floatingtoolbar_expressive.png" alt="The floating toolbar expressive.png" width="700"/>
42+
Floating toolbar show controls relevant to the current page
43+
44+
The **floating toolbar** was created for more versatility, greater amounts of
45+
actions, and more variety in where it's placed.
46+
[More on M3 Expressive](https://m3.material.io/blog/building-with-m3-expressive)
47+
48+
**Types and naming:**
49+
50+
* Added **floating toolbar** with the following attributes:
51+
52+
* Layout: Horizontal or vertical
53+
* Color: Standard or vibrant
54+
* Flexibility: Can hold many elements and components. Can be paired with
55+
FAB.
56+
57+
## Key properties
1858

19-
Vertical Floating Toolbar | Horizontal Floating Toolbar
20-
-------------------------------------------------------------------------- | ------------------------
21-
![Vertical floating toolbar](assets/floatingtoolbar/ftbvertical.png) | ![Horizontal floating toolbar](assets/floatingtoolbar/ftbhorizontal.png)
59+
### Container attributes
2260

23-
**Contents**
61+
Element | Attribute | Related methods | Default value
62+
----------------------- | ------------------------------------ | --------------- | -------------
63+
**Color** | `app:backgroundTint` | N/A | standard is `?attr/colorSurfaceContainer`, vibrant is `?attr/colorPrimaryContainer`
64+
**Shape** | `app:shapeAppearance` | N/A | `50% rounded`
65+
**Left inset margin** | `app:marginLeftSystemWindowInsets` | N/A | `true`
66+
**Top inset margin** | `app:marginTopSystemWindowInsets` | N/A | `true`
67+
**Right inset margin** | `app:marginRightSystemWindowInsets` | N/A | `true`
68+
**Bottom inset margin** | `app:marginBottomSystemWindowInsets` | N/A | `true`
2469

25-
* [Design and API Documentation](#design-and-api-documentation)
26-
* [Using Floating Toolbar](#using-floating-toolbar)
27-
* [Theming](#theming-a-floating-toolbar)
70+
### Styles
2871

29-
## Design and API Documentation
72+
Element | Style | Theme attribute
73+
------------------ | ------------------------------------------ | ---------------
74+
**Standard style** | `Widget.Material3.FloatingToolbar` | `?attr/floatingToolbarStyle`
75+
**Vibrant style** | `Widget.Material3.FloatingToolbar.Vibrant` | `?attr/floatingToolbarVibrantStyle`
3076

31-
* Google Material3 Spec in progress
32-
* API Reference in progress
77+
Floating toolbar also recommends a special style for specific components for
78+
when they are inside of a floating toolbar. Currently, the floating toolbar
79+
styles also include a theme overlay for `?attr/materialButtonStyle`,
80+
`?attr/materialIconButtonStyle`, and `?attr/borderlessButtonStyle` to style
81+
buttons inside of a floating toolbar.
82+
83+
For the full list, see
84+
[styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/styles.xml)
85+
and
86+
[floating toolbar attributes](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/attrs.xml)
3387

34-
## Using Floating Toolbar
88+
## Code implementation
3589

36-
Before you can use the Floating Toolbar, you need to add a dependency to
37-
the Material Components for Android library. For more information, go to the
90+
Before you can use the floating toolbar, you need to add a dependency to the
91+
Material components for Android library. For more information, go to the
3892
[Getting started](https://github.com/material-components/material-components-android/tree/master/docs/getting-started.md)
3993
page.
4094

95+
### Adding floating toolbar
96+
4197
Here's what a typical layout would look like:
4298

4399
```xml
@@ -71,7 +127,7 @@ Here's what a typical layout would look like:
71127
android:layout_margin="16dp">
72128

73129
<!-- floating toolbar sample content -->
74-
<com.google.android.material.overflow.OverflowLinearLayout
130+
<com.google.android.material.overflow.OverflowLinearLayout
75131
android:id="@+id/floating_toolbar_child"
76132
android:layout_width="wrap_content"
77133
android:layout_height="wrap_content"
@@ -150,25 +206,32 @@ attribute:
150206
</com.google.android.material.floatingtoolbar.FloatingToolbarLayout>
151207
```
152208

153-
This behavior will be disabled when Talkback is enabled for a11y reasons. See [how to make floating toolbars accessible](#making-floating-toolbar-accessible).
209+
This behavior will be disabled when TalkBack is enabled for a11y reasons. See
210+
[how to make floating toolbars accessible](#making-floating-toolbar-accessible).
154211

155-
Note that the default M3 style is the horizontal standard color styling. Vibrant color or vertical styles should be explicitly set on the `FloatingToolbarLayout`. M3 stylings for specific components may also be defined, such as for icon buttons. These are recommended to be set explicitly on the corresponding components inside `FloatingToolbarLayout`. See the full list of [styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/styles.xml).
212+
Note that the default M3 style is the horizontal standard color styling. Vibrant
213+
color or vertical styles should be explicitly set on the
214+
`FloatingToolbarLayout`. M3 stylings for specific components may also be
215+
defined, such as for icon buttons. These are recommended to be set explicitly on
216+
the corresponding components inside `FloatingToolbarLayout`. See the full list
217+
of
218+
[styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/styles.xml).
156219

157220
API and source code:
158221

159222
* `FloatingToolBar`
160223
* [Class source](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/FloatingToolbarLayout.java)
161224

162-
### Making Floating Toolbar accessible
225+
### Making floating toolbar accessible
163226

164-
You should set a `contentDescription` on all the actions in the Floating Toolbar
227+
You should set a `contentDescription` on all the actions in the floating toolbar
165228
so that screen readers like TalkBack can properly announce what each action
166229
represents.
167230

168-
You can also control the ordering of the Talkback focus through the
231+
You can also control the ordering of the TalkBack focus through the
169232
`accessibilityTraversalBefore` and `accessibilityTraversalAfter` flags.
170233

171-
For example, if you want the Floating Toolbar to gain Talkback focus first, you
234+
For example, if you want the floating toolbar to gain TalkBack focus first, you
172235
can set these accessibility flags like below:
173236

174237
```xml
@@ -198,17 +261,17 @@ android:id="@+id/floating_toolbar"
198261
</com.google.android.material.floatingtoolbar.FloatingToolbarLayout>
199262
```
200263

201-
#### Talkback
264+
#### TalkBack
202265

203266
Floating toolbars can optionally use the `CoordinatorLayout.Behavior`
204267
`HideViewOnScrollBehavior` to hide the floating toolbar on scroll. This behavior
205-
is disabled when Talkback is enabled disabled due to screen readers not being
268+
is disabled when TalkBack is enabled disabled due to screen readers not being
206269
able to see it if the floating toolbar is hidden when scrolled.
207270

208-
If using a Floating toolbar in a layout that obscures any content when
209-
hide on scroll is disabled, make sure to add the appropriate padding to the
210-
content. For example, if the floating toolbar is on the bottom and it is
211-
obscuring the content, bottom padding should be added to the content.
271+
If using a floating toolbar in a layout that obscures any content when hide on
272+
scroll is disabled, make sure to add the appropriate padding to the content. For
273+
example, if the floating toolbar is on the bottom and it is obscuring the
274+
content, bottom padding should be added to the content.
212275

213276
See below for an example:
214277

@@ -227,58 +290,24 @@ if (am != null && am.isTouchExplorationEnabled) {
227290
}
228291
```
229292

230-
### Anatomy and key properties
231-
232-
The following is an anatomy diagram for the floating toolbar:
233-
234-
![Floating toolbar anatomy diagram](assets/floatingtoolbar/ftbanatomy.png)
235-
236-
1. Container
237-
2. Content
238-
239-
#### Container attributes
293+
## Customizing floating toolbar
240294

241-
**Element** | **Attribute** | **Related methods** | **Default value**
242-
----------------------- | ------------------------------------ | ------------------- | -----------------
243-
**Color** | `app:backgroundTint` | N/A | standard is `?attr/colorSurfaceContainer`, vibrant is `?attr/colorPrimaryContainer`
244-
**Shape** | `app:shapeAppearance` | N/A | `50% rounded`
245-
**Left inset margin** | `app:marginLeftSystemWindowInsets` | N/A | `true`
246-
**Top inset margin** | `app:marginTopSystemWindowInsets` | N/A | `true`
247-
**Right inset margin** | `app:marginRightSystemWindowInsets` | N/A | `true`
248-
**Bottom inset margin** | `app:marginBottomSystemWindowInsets` | N/A | `true`
295+
### Theming floating toolbar
249296

250-
#### Styles
297+
Floating toolbars support the customization of color and typography.
251298

252-
**Element** | **Style**
253-
------------------ | ------------------------------------------
254-
**Standard style** | `Widget.Material3.FloatingToolbar`
255-
**Vibrant style** | `Widget.Material3.FloatingToolbar.Vibrant`
256-
257-
Standard style theme attribute: `?attr/floatingToolbarStyle`
258-
Vibrant style theme attribute: `?attr/floatingToolbarVibrantStyle`
259-
260-
Floating Toolbar also recommends a special style for specific components for
261-
when they are inside of a floating toolbar. Currently, the Floating Toolbar
262-
styles also include a theme overlay for `?attr/materialButtonStyle`,
263-
`?attr/materialIconButtonStyle`, and `?attr/borderlessButtonStyle` to
264-
style buttons inside of a Floating Toolbar.
265-
266-
See the full list of
267-
[styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/styles.xml) and
268-
[floating toolbar attributes](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/res/values/attrs.xml)
269-
270-
## Theming a Floating Toolbar
299+
API and source code:
271300

272-
Floating Toolbar supports [Material Theming](https://m3.material.io/foundations/customization),
273-
which can customize color and typography.
301+
* `FloatingToolBarLayout`
302+
* [Class source](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/floatingtoolbar/FloatingToolbarLayout.java)
274303

275-
### Floating Toolbar theming example
304+
#### Floating toolbar theming example
276305

277-
The following example shows a Floating Toolbar with Material Theming.
306+
The following example shows a floating toolbar with Material theming.
278307

279-
![Floating Toolbar theming example](assets/floatingtoolbar/ftbtheming.png)
308+
<img src="assets/floatingtoolbar/ftbtheming.png" alt="Floating toolbar theming example" width="600"/>
280309

281-
#### Implementing floating toolbar theming
310+
##### Implementing floating toolbar theming
282311

283312
Use theme attributes and a style in `res/values/styles.xml` which apply to all
284313
floating toolbars and affect other components:
@@ -336,7 +365,8 @@ all floating toolbars but do not affect other components:
336365
</style>
337366
```
338367

339-
Or use the style in the layout, which affects only this specific floating toolbar:
368+
Or use the style in the layout, which affects only this specific floating
369+
toolbar:
340370

341371
```xml
342372
<com.google.android.material.floatingtoolbar.FloatingToolbarLayout
76.3 KB
Loading

0 commit comments

Comments
 (0)