Five layout modes for android
Android layout is an important part of application interface development. In Android, there are five layout Methods: LinearLayout (linear layout), FrameLayout (Framework layout), and AbsoluteLayout (absolute layout ), relativeLayout (relative layout) and TableLayout (table layout ). In windows, the preview function is available. You can view the layout style in xml, which is not available in linux. 1. Linear layout of LinearLayout. This is a div from the outer frame. First, it is listed on the screen one by one. Each LinearLayout can be divided into vertical layout (android: orientation = "vertical") and horizontal layout (android: orientation = "horizontal "). In vertical layout, each row has only one element, and multiple elements are vertical down in sequence. in horizontal layout, there is only one row, and each element is arranged to the right in sequence. LinearLayout has an important attribute android: layout_weight = "1". In vertical layout, this weight represents the line spacing; in horizontal layout, it represents the column width; the larger the weight value, the larger the value. The preview in the linear layout is exactly the same as that in the real machine. TextView occupies a certain amount of space and has a certain width and height without a value assignment. Pay special attention to this. 2. FrameLayout is the simplest layout object. It is customized as a blank standby area on your screen, and then you can fill in a single object-for example, an image you want to publish. All child elements are fixed in the upper left corner of the screen. You cannot specify a position for a child element in FrameLayout. The next child element directly overwrites the previous child element and blocks them in part or whole (unless the last child element is transparent ). 3. The layout of AbsoluteLayout is very simple. The main attribute is the absolute position of the component defined by layout_x and layout_y respectively. That is, the x and y values of the coordinate axes (0, 0) in the upper left corner of the screen increase when the coordinate values move downward or to the right. AbsoluteLayout has no page border and allows elements to overlap with each other (although not recommended ). We generally do not recommend AbsoluteLayout unless you have a legitimate reason to use it, because it makes the interface code too rigid, so that it can work well on different devices. 4. Relative layout of RelativeLayout can be understood as the layout of a reference object. Android: layout _ direction = id indicates that android: layout_align is aligned with android: layout_to direction Of = id indicates that the current control is placed under the control whose id is la1. Android: layout_alignParentRight = "true": Align the right end of the current control with the right end of the parent control. The attribute value can only be true or false. The default value is false. Android: layout_marginLeft = "10dip" to empty the space on the left of the current control. Android: layout_toLeftOf = "@ id/true": place the current control on the left of the control whose id is true. Android: layout_alignTop = "@ id/OK" to align the current control with the upper end of the control whose id is OK. 5. The TableLayout Table layout is similar to the Table in Html. Each TableLayout contains the table row TableRow, which can define each element. Each TableRow defines a row (in fact, you can define other sub-objects, which will be explained below ). The TableLayout container does not display the border lines of row, cloumns, or cell. Each row has 0 or more cells, and each cell has one View object. A table consists of columns and rows in multiple cells. The table allows cells to be empty. Cells cannot span columns, which is different from HTML. TabRow only applies to rows, regardless of columns (custom columns ).