1. Relative layout
Simply put, by describing where each component is located, the Layout_below used, and so on, is the control of the position relationship between the component and the component.
2. Absolute layout
is to determine the location by describing his x, y coordinates.
3. Linear layout
There are two types that are horizontal and vertical, and generally use linear layouts to arrange a multitude of components
3. Frame layout
I feel like a layer of layers, by default, multiple components are in the same location, so you need to modify the location. You can also choose whether or not to display.
This can be used to describe the control method of the video player pause key.
The code is as follows.
<?XML version= "1.0" encoding= "Utf-8"?><Framelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" > <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:gravity= "Center"Android:text= "I am the video player, I am playing the text"android:visibility= "visible" /> <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:gravity= "Center" > <ImageViewAndroid:id= "@+id/iv"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:gravity= "Center"android:src= "@drawable/ic_launcher"android:visibility= "Invisible" /> </LinearLayout><LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Horizontal" > <ButtonAndroid:id= "@+id/button1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Play"Android:onclick= "Play"/> <ButtonAndroid:id= "@+id/button2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Pause"Android:onclick= "Pause"/></LinearLayout></Framelayout>
Packagecom.example.layout;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.ImageView; Public classMainactivityextendsActivity { PublicImageView IV; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.frame); IV=(ImageView) Findviewbyid (R.ID.IV); } Public voidPlay (View Ciew) {iv.setvisibility (view.invisible); } Public voidPause (View ciew) {iv.setvisibility (view.visible); }}
The code is simple. However, frame layout and relative layout are used.
5. Network layout
The function of this is like a grid. The functionality of the Java GUI is the same.
The
summarizes these layouts, which can be analogous to several layout types in Javagui.