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)
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.
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.
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.
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
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.
- Android implementation of loading advertising images and countdown opening screen layout
- Android dynamic layout method to dynamically join TextView and ListView
- ListView Item layout optimization tips in Android
- Android code to achieve top and bottom layout of pictures and text
- Android implements streaming layout for popular tags
- Android use java to dynamically add and modify layout
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file