OverflowLinearLayout


public class OverflowLinearLayout


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 com.google.android.material.floatingtoolbar.FloatingToolbarLayout and the com.google.android.material.dockedtoolbar.DockedToolbarLayout.

Summary

Nested types

A LinearLayout.LayoutParams implementation for OverflowLinearLayout.

Public constructors

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

Public methods

OverflowLinearLayout.LayoutParams
generateLayoutParams(AttributeSet attrs)
Drawable

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

Set<View>

Returns the current set of overflowed views.

boolean

Whether the OverflowLinearLayout currently has items overflowed.

void
setOverflowButtonIcon(Drawable icon)

Sets the icon to show for the overflow button.

void
setOverflowButtonIconResource(int iconResourceId)

Sets the icon to show for the overflow button.

Protected methods

boolean
checkLayoutParams(LayoutParams p)
OverflowLinearLayout.LayoutParams
OverflowLinearLayout.LayoutParams
generateLayoutParams(LayoutParams p)
void
onMeasure(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.

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.

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.

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)