Skip to main content

LinearLayout

declare class LinearLayout extends ViewGroup {}

A layout that arranges other views either horizontally in a single column or vertically in a single row.

Attribute

gravity

<LinearLayout gravity="center">
...
</LinearLayout>
  • Description

    Specifies how an object should position its content, on both the X and Y axes, within its own bounds.
    center_vertical center_horizontal none top bottom left right center fill fill_verticalfill_horizontal axis_clip clip_vertical clip_horizontal

orientation

<LinearLayout orientation="horizontal">
...
</LinearLayout>
  • Description

    Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column.

LinearLayout.LayoutParams

Per-child layout information associated with ViewLinearLayout.

declare class LayoutParams extends ViewGroup.MarginLayoutParams {}

Attribute

layout_gravity

<LinearLayout>
<View layout_gravity="center"/>
</LinearLayout>
  • Description

    Gravity specifies how a component should be placed in its group of cells.
    center_vertical center_horizontal none top bottom left right center fill``fill_verticalfill_horizontal axis_clip clip_vertical clip_horizontal

layout_weight

<LinearLayout>
<View layout_gravity="1"/>
</LinearLayout>
  • Description

    Indicates how much of the extra space in the LinearLayout is allocated to the view associated with these LayoutParams.