Skip to content

Commit 362c64c

Browse files
Material Design Teamhunterstich
authored andcommitted
[Docs] Updated Overflow Linear Layout doc to make it more user friendly
PiperOrigin-RevId: 777433598
1 parent 72a0cec commit 362c64c

File tree

1 file changed

+62
-52
lines changed

1 file changed

+62
-52
lines changed

docs/components/OverflowLinearLayout.md

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
# Overflow Linear Layout
2-
3-
The `OverflowLinearLayout` is usually used with the [FloatingToolbar](https://github.com/material-components/material-components-android/tree/master//docs/components/FloatingToolbar.md)
4-
and the [DockedToolbar](https://github.com/material-components/material-components-android/tree/master//docs/components/DockedToolbar.md).
1+
<!--docs:
2+
title: "Overflow linear layout"
3+
layout: detail
4+
section: components
5+
excerpt: "The overflow linear layout is usually used with the FloatingToolbar and DockedToolbar."
6+
iconId: overflow
7+
path: /catalog/overflow-linear-layout/
8+
-->
9+
10+
# Overflow linear layout
11+
12+
The `OverflowLinearLayout` is usually used with the
13+
[floatingtoolbar](FloatingToolbar.md) and the [dockedtoolbar](DockedToolbar.md).
514
It allows for its children to be automatically hidden/shown depending on its
615
parent's max size. The hidden children are put in an overflow menu, and an
716
overflow button is added as the last child of its parent layout.
@@ -11,7 +20,43 @@ decisions, you'll need to add/remove the desired view(s), instead of changing
1120
their visibility, as the `OverflowLinearLayout` will determine the final
1221
visibility value of its children.
1322

14-
## Using Overflow Linear Layout
23+
## Key properties
24+
25+
### `OverflowLinearLayout` attributes
26+
27+
Element | Attribute | Related methods | Default value
28+
------------------------ | ------------------------ | --------------------------------------------------------------------------------------- | -------------
29+
**Overflow button icon** | `app:overflowButtonIcon` | `setOverflowButtonIcon`<br/>`setOverflowButtonIconResource`<br/>`getOverflowButtonIcon` | `@drawable/abc_ic_menu_overflow_material`
30+
31+
### `OverflowLinearLayout_Layout` attributes
32+
33+
Attributes for the children of `OverflowLinearLayout`:
34+
35+
| Element | Attribute | Related methods | Default value |
36+
| ----------- | ------------------------- | --------------- | ------------- |
37+
| **Overflow | `app:layout_overflowText` | N/A | `null` |
38+
: menu's item : : : :
39+
: text** : : : :
40+
| **Overflow | `app:layout_overflowIcon` | N/A | `null` |
41+
: menu's item : : : :
42+
: icon** : : : :
43+
44+
### `OverflowLinearLayout` styles
45+
46+
Element | Style | Theme attribute
47+
------------------- | ----------------------------------------- | ---------------
48+
**Style** | `Widget.Material3.OverflowLinearLayout` | `?attr/overflowLinearLayoutStyle`
49+
**Button overflow** | `overflowLinearLayoutOverflowButtonStyle` | `?attr/overflowLinearLayoutOverflowButtonStyle`
50+
**Popup overflow** | `overflowLinearLayoutPopupMenuStyle` | `?attr/overflowLinearLayoutPopupMenuStyle`
51+
52+
For the full list, see
53+
[styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/res/values/styles.xml)
54+
and
55+
[overflow linear layout attributes](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/res/values/attrs.xml)
56+
57+
## Code implementation
58+
59+
### Adding overflow linear layout
1560

1661
A common usage looks like:
1762

@@ -36,64 +81,29 @@ When using `OverflowLinearLayout`, you should set `app:layout_overflowText` on
3681
on each child, as that will show as the text of the menu item that corresponds
3782
to the hidden child. Optionally, you can also set `app:layout_overflowIcon`.
3883

39-
See
40-
[FloatingToolbar](https://github.com/material-components/material-components-android/tree/master//docs/components/FloatingToolbar.md)
41-
and [DockedToolbar](https://github.com/material-components/material-components-android/tree/master//docs/components/DockedToolbar.md)
84+
See [floatingtoolbar](FloatingToolbar.md) and [dockedtoolbar](DockedToolbar.md)
4285
for example usages with those components.
4386

4487
API and source code:
4588

46-
* `OverflowLinearLayout`
47-
* [Class source](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/OverflowLinearLayout.java)
89+
* `OverflowLinearLayout`
90+
* [Class source](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/OverflowLinearLayout.java)
4891

49-
### Making Overflow Linear Layout accessible
92+
### Making overflow linear layout accessible
5093

5194
As mentioned above, you should set `app:layout_overflowText` on each direct
5295
child of `OverflowLinearLayout` that may be overflowed, so that the overflow
5396
menu items have text that can be read by screen readers.
5497

55-
## Attributes and styles
56-
57-
### `OverflowLinearLayout` attributes
58-
59-
**Element** | **Attribute** | **Related methods** | **Default value**
60-
--------------------------|--------------------------|-----------------------------------------------------------------------------------------|-------------------------------------------
61-
**Overflow button icon** | `app:overflowButtonIcon` | `setOverflowButtonIcon`<br/>`setOverflowButtonIconResource`<br/>`getOverflowButtonIcon` | `@drawable/abc_ic_menu_overflow_material`
62-
63-
### `OverflowLinearLayout_Layout` attributes
64-
65-
Attributes for the children of `OverflowLinearLayout`:
66-
67-
**Element** | **Attribute** | **Related methods** | **Default value**
68-
------------------------------------|---------------------------------|---------------------|-------------------
69-
**Overflow menu's item text** | `app:layout_overflowText` | N/A | `null`
70-
**Overflow menu's item icon** | `app:layout_overflowIcon` | N/A | `null`
71-
72-
### `OverflowLinearLayout` Styles
73-
74-
**Element** | **Style**
75-
-------------|-------------------------------------------------------
76-
**Style** | `Widget.Material3.OverflowLinearLayout`
77-
78-
Style theme attribute: `?attr/overflowLinearLayoutStyle`
79-
80-
Button overflow theme attribute: `?attr/overflowLinearLayoutOverflowButtonStyle`
81-
(defaults to `?attr/materialIconButtonStyle`)
82-
83-
Popup overflow menu theme attribute: `?attr/overflowLinearLayoutPopupMenuStyle`
84-
(defaults to `?attr/popupMenuStyle`)
85-
86-
See the full list of
87-
[styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/res/values/styles.xml) and
88-
[overflow linear layout attributes](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/overflow/res/values/attrs.xml)
98+
## Customizing overflow linear layout
8999

90-
## Theming an Overflow Linear Layout
100+
### Theming overflow linear layout
91101

92-
Overflow Linear Layout supports
93-
[Material Theming](https://m3.material.io/foundations/customization),
94-
which can customize color, shape and typography.
102+
Overflow linear layout supports
103+
[Material theming](https://m3.material.io/foundations/customization), which can
104+
customize color, shape and typography.
95105

96-
### Implementing overflow linear layout theming
106+
#### Implementing overflow linear layout theming
97107

98108
Use theme attributes and a style in `res/values/styles.xml` which apply to all
99109
overflow linear layouts and affect other components:
@@ -137,8 +147,8 @@ all overflow linear layouts but do not affect other components:
137147
</style>
138148
```
139149

140-
Or use the style in the layout, which affects only this specific overflow
141-
linear layout:
150+
Or use the style in the layout, which affects only this specific overflow linear
151+
layout:
142152

143153
```xml
144154

0 commit comments

Comments
 (0)