这篇文章主要为大家详细介绍了Android五大布局与实际应用,感兴趣的小伙伴们可以参考一下
Android总体有五大布局:
- 线性布局(LiearLayout): 屏幕垂直或水平方向布局。
- 帧布局(FrameLayout):控件从屏幕左上角开始布局。
- 相对布局(RelativeLayout): 以其他控件为参照布局。
- 绝对布局(AbsoluteLayout):以屏幕坐标布局。
-
表格布局(TableLayout):按照行列方式布局。

一、LinearLayout
线性布局在开发中使用最多,具有垂直方向与水平方向的布局方式,通过设置属性“android:orientation”控制方向,属性值垂直(vertical)和水平(horizontal),默认水平方向。
在使用orientation时需要注意一个问题,假如我们使用默认布局方向,即水平方向,若LinearLayout中存在不止一个控件且都未设置具体宽度,即这样的布局代码:
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>则会出现下面的错误:










