Home>

Android layout is an important part of application interface development.In android, there are five layout methods,They are:framelayout (frame layout), linearlayout (linear layout), absolutelayout (absolute layout), relativelayout (relative layout), tablelayout (table layout), we will give you a detailed explanation through this article one by one

Android is very crazy now,So the information about android learning on the Internet has sprung up,There are so many basic things like these basic things,I will record the difficulties I have encountered and how to solve them.Once you can review it yourself, if you encounter similar problems later, you can take it directly.Secondly, it can help the beginners a little.

Android layout is an important part of application interface development.In android, there are five layout methods,They are:framelayout

Bureau), linearlayout (linear layout), absolutelayout (absolute layout), relativelayout (relative layout), tablelayout (table layout)

Framelayout

This layout can be seen as a pile of things at the foot of the wall,There is a square box on the top left corner of the wall,We put the first thing,To put another one,Then on top of where it was,Put them in this order,Will cover the original thing.This layout is relatively simple,Can only put a little more simple things.

Second, linearlayout

Linear layout,this thing,It can be understood as a div from the outer frame. He is listed on the screen from top to bottom.Each linearlayout can be divided into vertical layouts

(Android:orientation="vertical") and horizontal layout (android:orientation="horizontal"

). When laid out vertically,There is only one element per line,Multiple elements go down vertically in turn;When laid out horizontally,Only one line,Each element is arranged to the right in turn.

There is an important attribute android:layout_weight="1" in linearlayout. When this weight is laid out vertically,Representative line spacingColumn width when horizontal;The larger the weight value is, the larger it is.

Third, absolutelayout

Absolute layout is like a div specifying the absolute property, using 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 when switching casually vertically,Often go wrongAnd when there are multiple elements,Calculation is cumbersome.

Fourth, relativelayout

Relative layout can be understood as a reference element,To position the layout.The main attributes are:

Relative to an element

android:layout_below="@ id/aaa" The element is below the id aaa

android:layout_toleftof="@ id/bbb" Change the left side of the element to bbb

Relative to the parent element

android:layout_alignparentleft="true" Left-align on the parent element

android:layout_alignparentright="true" right-align the parent element

You can also specify margins, etc.See details in api

Five, tablelayout

The table layout is similar to the table in html. There is a table row in each tablelayout. Each element in the tablerow can be specifically defined.Set his alignment android:gravity="".

Each layout has its own suitable way,In addition, these five layout elements can be applied nested with each other.Make a beautiful interface.

  • Previous Android programming method to add text content to sqlite table
  • Next ASPNET verification code implementation (with source code)