# OverflowLinearLayout

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/overflow/OverflowLinearLayout.java)

*** ** * ** ***


```
public class OverflowLinearLayout
```

<br />

*** ** * ** ***

Provides an implementation of an overflow linear layout.

The OverflowLinearLayout will automatically hide/show its children depending on the current available screen space and/or the max size of its parent layout. If there is not enough space to show all children, the ones that do not fit will be put in an overflow menu, and an overflow button will be automatically added as the last child of the layout.

Note: if you'd like to hide/show children independently from this layout's decisions, you'll need to add/remove the desired view(s), instead of changing their visibility, as the OverflowLinearLayout will determine the final visibility value of its children.

The OverflowLinearLayout is commonly used with the `https://developer.android.com/reference/com/google/android/material/floatingtoolbar/FloatingToolbarLayout` and the `https://developer.android.com/reference/com/google/android/material/dockedtoolbar/DockedToolbarLayout`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout.LayoutParams` A LinearLayout.LayoutParams implementation for `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#OverflowLinearLayout(Context)(Context context)` |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#OverflowLinearLayout(Context,AttributeSet)(Context context, AttributeSet attributeSet)` |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#OverflowLinearLayout(Context,AttributeSet,int)( Context context, AttributeSet attributeSet, int defStyleAttr )` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#generateLayoutParams(AttributeSet)(AttributeSet attrs)` |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#getOverflowButtonIcon()()` Returns the icon shown for the overflow button, if present. |
| `https://developer.android.com/reference/java/util/Set<View>` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#getOverflowedViews()()` Returns the current set of overflowed views. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#isOverflowed()()` Whether the OverflowLinearLayout currently has items overflowed. |
| `void` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIcon(Drawable)(Drawable icon)` Sets the icon to show for the overflow button. |
| `void` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIconResource(int)(int iconResourceId)` Sets the icon to show for the overflow button. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#checkLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#generateDefaultLayoutParams()()` |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#generateLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#onMeasure(int,int)(int widthMeasureSpec, int heightMeasureSpec)` |

## Public constructors

### OverflowLinearLayout

```
public OverflowLinearLayout(Context context)
```

### OverflowLinearLayout

```
public OverflowLinearLayout(Context context, AttributeSet attributeSet)
```

### OverflowLinearLayout

```
public OverflowLinearLayout(
    Context context,
    AttributeSet attributeSet,
    int defStyleAttr
)
```

## Public methods

### generateLayoutParams

```
public OverflowLinearLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
```

### getOverflowButtonIcon

```
public Drawable getOverflowButtonIcon()
```

Returns the icon shown for the overflow button, if present.

ref com.google.android.material.R.styleable#OverflowLinearLayout_overflowButtonIcon

| Returns |
|---|---|
| `Drawable` | the overflow button icon, if present. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIcon(Drawable)` |   |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIconResource(int)` |   |

### getOverflowedViews

```
public Set<View> getOverflowedViews()
```

Returns the current set of overflowed views.

### isOverflowed

```
public boolean isOverflowed()
```

Whether the OverflowLinearLayout currently has items overflowed.

### setOverflowButtonIcon

```
public void setOverflowButtonIcon(Drawable icon)
```

Sets the icon to show for the overflow button.

ref com.google.android.material.R.styleable#OverflowLinearLayout_overflowButtonIcon

| Parameters |
|---|---|
| `Drawable icon` | Drawable to use for the overflow button's icon. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIconResource(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#getOverflowButtonIcon()` |   |

### setOverflowButtonIconResource

```
public void setOverflowButtonIconResource(int iconResourceId)
```

Sets the icon to show for the overflow button.

ref com.google.android.material.R.styleable#OverflowLinearLayout_overflowButtonIcon

| Parameters |
|---|---|
| `int iconResourceId` | drawable resource ID to use for the overflow button's icon. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#setOverflowButtonIcon(Drawable)` |   |
| `https://developer.android.com/reference/com/google/android/material/overflow/OverflowLinearLayout#getOverflowButtonIcon()` |   |

## Protected methods

### checkLayoutParams

```
protected boolean checkLayoutParams(LayoutParams p)
```

### generateDefaultLayoutParams

```
protected OverflowLinearLayout.LayoutParams generateDefaultLayoutParams()
```

### generateLayoutParams

```
protected OverflowLinearLayout.LayoutParams generateLayoutParams(LayoutParams p)
```

### onMeasure

```
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
```