线性布局(LinearLayout):在该标签下的所有子元素会根据orientation属性的值来决定是按行或者是按列来逐个显示。代码示例如下:
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
而相对布局,则是根据控件的相对位置而言,比如居于按钮的左侧或者右侧,示例如下:
android:layout_height="fill_parent">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
android:layout_alignTop="@id/button1"
android:text="@string/hello_world" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/app_name" />
分享
线性布局有两种
横和竖
控件和控件的排列是按线性排列的
比如控件1再放控件就是控件1控件3等等
它们之间的位置是按着顺序排列的(形成一条线一样)
表格布局就是行x列的这种方式
然后根据你的需求将控件添加在哪行哪列这种
相对布局
控件的位置是相对于某个参照物放置的
比如相对某个控件多少距离
相对上方多少距离等等放置控件