Linear layout - LinearLayout


(1) Overview
Linear layout has two directions, horizontal and vertical. Linear layout can also realize complex layout through nested layout.
Tip: Nested layouts refer to a layout that also includes several layouts.

Note: layout means the parent container, that is, if there is this layout , it is the layout in the parent container. If there is no layout, it means the height and width of the internal text.
Simply put, layout_width means the entire control in the parent container. The position
width represents the position of the text in the control

(2) Common properties

attribute name description
layout_height sets the height of the layout in the parent container
layout_width is the width of the layout in the parent container
orientation sets the layout orientation, with the following two values,
            vertical—vertical layout, the controls in the layout are arranged from top to bottom according to the order in which they are placed.
            horizontal——Horizontal layout, the controls in the layout are arranged from left to right according to the order in which they are placed.
background The background color or image of the layout
weight control weight ratio

 

illustrate:

1) In the layout setting of LinearLayout, if the layout of LinearLayout is a vertical layout (vertical), the value of our layout_gravity can only be the value of the horizontal position, but if it is a horizontal layout (horizontal), the value of our layout_gravity can only be Indicates the value of the vertical position.

2) weight value greater than 0 will fill the empty space in the horizontal or vertical direction

3) If the weight value is greater than 0 and equal, the free space is evenly distributed. If not equal, allocate free space in proportion to the size of the value

4) The weight value is 0, then the width is the set width

Also, if layout_width="wrap_content" is set, the free space is divided according to the relative size of weight
If layout_width="match_parent" is set, then the free space is divided according to the relative size of 1/weight



 




Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326917537&siteId=291194637