本文介绍 Android 界面开发中最基本的四种布局LinearLayout、RelativeLayout、FrameLayout、TableLayout 的使用方法及这四种布局中常用的属性。
LinearLayout 线性布局,布局中空间呈线性排列
RelativeLayout 相对布局,通过相对定位的方式,控制控件位置
FrameLayout 帧布局,最简单的布局,所有控件放置左上角
TableLayout 表格布局,以行列方式控制控件位置
四种布局示例
1.LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="垂直1" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="垂直2" />
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="水平1" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="水平2" />
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal">
android:layout_width&#