1、android线性布局最为基础,基本框架如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
其中 layout_width 和 layout_height 为该线性布局的高、宽;
wrap_content:设置该视图尺寸为能够展示内部全部控件;
match_parent/fill_parent:设置该视图尺寸为填满父视图全部空间;
其中orientation 设置线性布局的方向,及vertical(垂直)和horizantal(水平)
2、布局也可利用paddint\margin参数调整位置,如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dip"
android:orientation="vertical"
android:paddingTop="17dip" >
与web中的盒式布局类似,margin代表视图与父视图的边距,而padding代表自身与内部控件的边距
线性布局可采用gravity参数设置内部控件居中,例如:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_vertical">
转载于:https://www.cnblogs.com/Fredric-2013/archive/2013/01/23/4107336.html