1 LinearLayout
光注点在orientation上和权重的设置
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0C0C0"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_weight="4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
2 FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0C0C0"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:textSize="25dp"
android:text="1111"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<TextView
android:textSize="25dp"
android:text="222"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
</LinearLayout>
3 RelativeLayout
可以在属性中指定各个部件的距离和关系
4 绝对布局
不常用