· What is the linear layout?
The layout of a next container in a control consisting of a line is called a linear layout, LinearLayout control may control each of the horizontal or vertical arrangement
1, arrangement, by android: controlling the orientation property. There are two arrangement
1.垂直排列:android:orientation="vertical",其实就是从上往下一行一行显示
2.水平排列:android:orientation="horizontal",依次从左到右显示
2 · android: layout_gravity (alignment)
LinearLayout this property is most commonly a child element attribute refers to the alignment of the control with respect to the container
There are several options: top, bottom, left, right, center_vertical, center_horizontal, center, fill
As effects, there are the following three buttons,
First I set the alignment to left: android: layout_gravity = "left"
The second level of the center: android: layout_gravity = "center_horizontal"
The third right justified: android: layout_gravity = "right"
3.weight (weight)
LinearLayout layout layout_weight attribute is used to allocate space occupied in the control LinearLayout in size, we look
We button3 add android: layout_weight = "1", you can see it the other spare screen space to account for.
We look at a situation, we button1 add android: layout_weight = "1", button2 as android: layout_weight = "2",
button3 is android: layout_weight = "3", in fact, the entire screen is divided into 6 parts, button1 accounting for 1/6, button2 accounting 2/6, button representing 3/6