First type: linear layout
This layout is relatively simple, either vertically or horizontally.
[HTML]View Plaincopy
-
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
android:padding= "10DP" >
<textview
Android:id= "@+id/text"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/type"/>
<edittext
Android:id= "@+id/et_entry"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:hint= "@string/hello"
android:background= "#ffffff"/>
<button
Android:id= "@+id/ok"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/ok"/>
<button
Android:id= "@+id/cancel"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/cancel"/>
</LinearLayout>
The effect is as follows:
The second type: relative layout
Relative layout: In contrast to a reference position, you must have a reference before you can determine the position of the next control, such as a first, and then B relative to a, on the right, bottom, or position of a. Of course, Android can also be relative to the parent form.
1 <Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android" 2 Xmlns:tools= "Http://schemas.android.com/tools" 3 Android:layout_width= "Match_parent" 4 Android:layout_height= "100DP" 5 Tools:context=". Mainactivity "> 6 <TextView7 Android:id= "@+id/tv_title" 8 Android:layout_width= "Wrap_content" 9 Android:layout_height= "Wrap_content" Ten Android:layout_marginleft= "10DP" One Android:layout_margintop= "10DP" A Android:textcolor= "#660000" - android:textsize= "20SP" - Android:text= "I am the big text" /> the <TextView - Android:layout_below= "@id/tv_title" - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" + Android:layout_marginleft= "10DP" - Android:layout_margintop= "10DP" + Android:textcolor= "#660000" A android:textsize= "14SP" at Android:text= "I am a small text" /> - <CheckBox - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - Android:layout_alignparentleft= "true" - android:layout_centervertical= "true" in /> - </Relativelayout>
This layout looks like this:
The third type: Table layout
[HTML]View Plaincopy
Table layout: For example, a few rows of columns of formatting, such as what Excel looks like
[HTML]View Plaincopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <tablelayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#000000"
- android:stretchcolumns="1" >
- <TableRow >
- <TextView
- android:text="name"
- android:padding="10dip"
- android:textcolor="#ffffff"/>
- <EditText
- android:layout_marginleft="20DP"
- android:background="#ffffff"
- />
- </TableRow>
- <TableRow >
- <TextView
- android:text="password"
- android:padding="10dip"
- android:textcolor="#ffffff"/>
- <EditText
- android:layout_marginleft="20DP"
- android:background="#ffffff"
- android:password="true"
- />
- </TableRow>
- </tablelayout>
The effect is as follows:
Fourth type: Frame layout
Frame layout: In fact, a relatively simple understanding is that a picture superimposed on the top of a picture, is the picture overlay
[HTML]View Plaincopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <framelayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="#ff0000" />
- <TextView
- android:layout_width="250DP"
- android:layout_height="390DP"
- android:layout_gravity="center"
- android:background="#dd0000" />
- <TextView
- android:layout_width="180DP"
- android:layout_height="300DP"
- android:layout_gravity="center"
- android:background="#bb0000" />
- <TextView
- android:layout_width="110DP"
- android:layout_height="210DP"
- android:layout_gravity="center"
- android:background="#990000" />
- <TextView
- android:layout_width="40DP"
- android:layout_height="120DP"
- android:layout_gravity="center"
- android:background="#770000" />
- </framelayout>
The effect is as follows:
Well, hit the common layout of the introduction is over, these are also in the process of looking at the code to find out, I hope to their own, will help others
Android Basic layout