Android study notes (11): Linear Layout LinearLayout

Linear Layout LinearLayout refers to arranging horizontally or vertically one after the other. When the arranged components are beyond the screen, the excess components will not be displayed again.

The XML attributes and corresponding methods supported by LinearLayout are shown in the table:

Attribute Name

Related Method

Description

android:baselineAligned

setBaselineAligned(boolean)

If set to false , will prevent the layout manager from aligning with the baseline of its children

android:baselineAlignedChildIndex

setBaselineAlignedChildIndex(int)

Specifies to align with the baseline of that child element

android:divider

setDividerDrawable(Drawable)

Set the divider between two buttons in vertical layout

android:gravity

setGravity(int)

Sets the alignment of components within the layout manager

android:measureWithLargestChild

setMeasureWithLargestChildEnabled(boolean)

If set to true , all child components will have the smallest size of the largest child element

android:orientation

setOrientation(int)

Sets the arrangement direction of components in the layout manager

android:weightSum

 

Define the maximum value of the sum of weights

 

 

The O rientation  property can be set to horizontal or vertical

The G ravity  property can be set to top , bottom , left , right , center_vertical , fill_vertical , center_horizontal , fill_horizontal , center , fill , clip_vertical .

An attribute can contain multiple values. It needs to be connected with "|" . Its meaning is as follows:

top

Put the object on top of its container. Does not change its size .

bottom

Place the object at the bottom of its container without changing its size .

left

Places the object to the left of its container without changing its size .

right

Places the object to the right of its container without changing its size .

center_vertical

 Vertical Alignment: Center alignment vertically.

fill_vertical

Fill vertically

center_horizontal

Horizontal Alignment: Align the center horizontally

fill_horizontal

fill horizontally

center

Centers the object vertically and horizontally without changing its size .

fill

Adds the horizontal and vertical size of the object as necessary to fully fill its container .

clip_vertical

Additional option for clipping the top and / or bottom contents of an object according to the container's sides Clipping is based on its vertical alignment setting: when top is aligned. Cut bottom; top when bottom is aligned; top and bottom otherwise .

Crop vertically

clip_horizontal

Additional option for clipping the contents of the left and / or right side of the object according to the container's sides Clipping is based on its horizontal alignment setting: when aligning to the left, the right side is cut; when aligning to the right, the left side is cut. In addition to clipping the left and right sides .

Crop horizontally

 

LinearLayout.LayoutParams is responsible for controlling the child elements inside the linear layout manager.

XML attributes supported by child elements such as the following

android:layout_gravity : Specifies the alignment of this child element in the layout manager

android:layout_weight : Specifies the weight of the child element in the layout manager

 

The attributes of layout_shenmu all control child elements.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324889680&siteId=291194637