Share five types of Android common layout methods _android

Source: Internet
Author: User

Android is crazy now, so online information about Android is springing up, and there's a lot more to it than that, and I'm going to record what I've used and how I've solved it. One can be reviewed in case you encounter similar problems in the future can take a look directly. Secondly can give beginners a little help.

Android layout is an important part of application interface development, in Android, there are five kinds of layout, respectively: Framelayout (frame cloth
Bureau), LinearLayout (linear layout), Absolutelayout (absolute layout), relativelayout (relative layout), tablelayout (table layout)

First, Framelayout

This layout can be seen as a pile of things, there is a square rectangle of the upper left corner of the wall, we put the first thing, to put another one, that is placed in the original position above, so in turn, will cover the original things. This layout is relatively simple, and can only put a little more simple things.

Second, LinearLayout

Linear layout, this thing, from the outer frame can be understood as a Div, he first is a list from the top down on the screen. Each linearlayout can be divided into vertical layout
(android:orientation= "vertical") and horizontal layout (android:orientation= "Horizontal"
)。 When vertical layout, there is only one element for each row, multiple elements descending vertically, and horizontal layout, only a row, each element in turn to the right.

LinearLayout has an important attribute android:layout_weight= "1", which represents the line spacing when the vertical layout, the level of the column, and the greater the weight value.

Third, Absolutelayout

An absolute layout is like a div that specifies the absolute property, with x,y coordinates to specify the position of the element android:layout_x= "20px"
Android:layout_y= "12px" This layout is also relatively simple, but in the vertical random switch, often problems, and multiple elements of the time, the calculation is more troublesome.

Four, Relativelayout

Relative layout can be understood as an element as a reference, to locate the layout of the way. The main properties are:

Relative to an element

android:layout_below= "@id/aaa" This element is under the ID AAA
android:layout_toleftof= "@id/bbb" Change the left side of the element is BBB

where relative to the parent element

Android:layout_alignparentleft= "true" to the left of the parent element
Android:layout_alignparentright= ' true ' aligns the parent element to the right

You can also specify the margins, etc., as detailed in the API

Five, Tablelayout

A table layout resembles a table in HTML. Each tablelayout has a table row Tablerow,tablerow inside can define each element concretely, set his alignment android:gravity= "".

Each layout has its own appropriate way, in addition, these five layout elements can be nested applications, make a beautiful interface.

To this end, all the tutorials in this article are over, and I want to help you learn about Android's common layout.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.