Stay organized with collections Save and categorize content based on your preferences.
added in version 25.1.0
belongs to Maven artifact


public class LinearLayoutCompat
extends ViewGroup

   ↳ android.view.View
     ↳ android.view.ViewGroup
Known Direct Subclasses

A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation(). You can also specify gravity, which specifies the alignment of all the child elements by calling setGravity() or specify that specific children grow to fill up any remaining space in the layout by setting the weight member of LinearLayoutCompat.LayoutParams. The default orientation is horizontal.

See the Linear Layout guide.

Also see LinearLayoutCompat.LayoutParams for layout attributes


Nested classes

class LinearLayoutCompat.LayoutParams

Per-child layout information associated with ViewLinearLayout. 




Show a divider at the beginning of the group.


Show a divider at the end of the group.


Show dividers between each item in the group.


Don't show any dividers.


Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

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

Public methods

LinearLayoutCompat.LayoutParams generateLayoutParams(AttributeSet attrs)
int getBaseline()
int getBaselineAlignedChildIndex()
Drawable getDividerDrawable()
int getDividerPadding()

Get the padding size used to inset dividers in pixels

int getGravity()

Returns the current gravity.

int getOrientation()

Returns the current orientation.

int getShowDividers()
float getWeightSum()

Returns the desired weights sum.

boolean isBaselineAligned()

Indicates whether widgets contained within this layout are aligned on their baseline or not.

boolean isMeasureWithLargestChildEnabled()

When true, all children with a weight will be considered having the minimum size of the largest child.

void onInitializeAccessibilityEvent(AccessibilityEvent event)
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
void setBaselineAligned(boolean baselineAligned)

Defines whether widgets contained in this layout are baseline-aligned or not.

void setBaselineAlignedChildIndex(int i)
void setDividerDrawable(Drawable divider)

Set a drawable to be used as a divider between items.

void setDividerPadding(int padding)

Set padding displayed on both ends of dividers.

void setGravity(int gravity)

Describes how the child views are positioned.

void setHorizontalGravity(int horizontalGravity)
void setMeasureWithLargestChildEnabled(boolean enabled)

When set to true, all children with a weight will be considered having the minimum size of the largest child.

void setOrientation(int orientation)

Should the layout be a column or a row.

void setShowDividers(int showDividers)

Set how dividers should be shown between items in this layout

void setVerticalGravity(int verticalGravity)
void setWeightSum(float weightSum)

Defines the desired weights sum.

boolean shouldDelayChildPressedState()

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
LinearLayoutCompat.LayoutParams generateDefaultLayoutParams()

Returns a set of layout parameters with a width of MATCH_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL.

LinearLayoutCompat.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
void onDraw(Canvas canvas)
void onLayout(boolean changed, int l, int t, int r, int b)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods

From class android.view.ViewGroup