AutoHidingVerticalLayout

public class AutoHidingVerticalLayout extends LinearLayout

A vertical layout that you can use to build an adaptive UI. It automatically hides or shows child views one at a time, depending on the available vertical height.

The default gravity of the layout is BOTTOM | END.

When vertical gravity is set to Gravity.BOTTOM (the default), child views are hidden starting from the top and going down. If vertical gravity is set to Gravity.TOP or Gravity.CENTER_VERTICAL, child views are hidden starting from the bottom and going up. You can set the LayoutParams property AutoHidingVerticalLayout.LayoutParams.isHighPriority on certain child views to make them the last to be hidden.

Note: This layout manages the visibility of its children dynamically during layout passes. To prevent layout bugs, don't modify the visibility of child views after adding them to this layout.

Note: Setting AutoHidingVerticalLayout.LayoutParams.isHighPriority must be done programmatically in Java or Kotlin code. It isn't supported via XML layout attributes.

MATCH_PARENT Children: When a child with LayoutParams.MATCH_PARENT height is evaluated during space distribution in survival order, it greedily absorbs all remaining vertical budget. Any children evaluated after a MATCH_PARENT view in survival order will face zero remaining height and be hidden (GONE).

Nested Class Summary

class AutoHidingVerticalLayout.LayoutParams Custom LinearLayout.LayoutParams that supports the isHighPriority attribute. 

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

AutoHidingVerticalLayout(Context context)
AutoHidingVerticalLayout(Context context, AttributeSet attrs)
AutoHidingVerticalLayout(Context context, AttributeSet attrs, int defStyleAttr)

Public Method Summary

AutoHidingVerticalLayout.LayoutParams
generateLayoutParams(AttributeSet attrs)
int
getChildSpacing()
Returns the spacing between child views in pixels.
void
setChildSpacing(int spacingInPixels)
Sets the spacing between child views in pixels.
void
setGravity(int gravity)
void
setHorizontalGravity(int horizontalGravity)
void
setOrientation(int orientation)
void
setVerticalGravity(int verticalGravity)

Inherited Method Summary

Public Constructors

public AutoHidingVerticalLayout (Context context)

Parameters
context

public AutoHidingVerticalLayout (Context context, AttributeSet attrs)

Parameters
context
attrs

public AutoHidingVerticalLayout (Context context, AttributeSet attrs, int defStyleAttr)

Parameters
context
attrs
defStyleAttr

Public Methods

public AutoHidingVerticalLayout.LayoutParams generateLayoutParams (AttributeSet attrs)

Parameters
attrs

public int getChildSpacing ()

Returns the spacing between child views in pixels.

public void setChildSpacing (int spacingInPixels)

Sets the spacing between child views in pixels.

Parameters
spacingInPixels

public void setGravity (int gravity)

Parameters
gravity

public void setHorizontalGravity (int horizontalGravity)

Parameters
horizontalGravity

public void setOrientation (int orientation)

Parameters
orientation

public void setVerticalGravity (int verticalGravity)

Parameters
verticalGravity