Learn Android layout together

This article briefly describes the simple application of layout in Android development, which belongs to basic knowledge and is only for learning and sharing.

In Android UI development, there are two main layout types: LinearLayout (linear layout) and relativelayout (relative layout). The two layout types have their own advantages and use scenarios.

Linear layout allows all sub elements to be arranged in a separate direction (horizontal or vertical). All elements are inserted one by one like a stack. Therefore, if it is in the vertical direction, there is only one element in each row. If it is horizontal, there is only one row. (as shown in Figure 1 below)

Android: orientation sets the direction of the arrangement. There are two main values: horizontal@H_ 404_ 4 @ (horizontal), vertical@H_ 404_ 4 @ (vertical).

android:layout_ Weight weight to allocate the remaining space proportionally.

(Figure 1) (Figure 2)

Relative layout means that all child elements are positioned in relative positions. An element can be positioned relative to the specified sibling element (e.g., left, right, upper, lower), or through the parent element (e.g., top, left, right, bottom, etc. of the layout control) (as shown in Figure 2 above). If you find multiple linear layouts nested in a page, you should replace it with a relative layout@ H_ 404_ 4@

The linear layout (relatively simple) is shown in Figure 1 below, and the relative layout (relatively complex) is shown in Figure 2 below

@H_ 419_ 113@

Figure 3 Figure 4

Linear layout

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>