一线性布局
线性布局中嵌套的组件之间不可以重叠, 有一个布局方向 ,水平或者竖直,依次排开.在竖直布局下,左对齐、右对齐,水平居中生效.在水平布局下,顶部对齐、底部对齐、竖直居中生效. 线性布局中有个很重要的概念----权重:按比例分配屏幕的剩余宽度或者高度 谷歌推荐使用时将空间宽度或高度设置为0dp.在定义布局颜色时候,我们可以使用谷歌给我们预定义好的颜色代码"@android:color/dark"
简单示例:
简单示例:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#ff0000"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#ffffff"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#000000"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
>
<TextView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#00ff00"
/>
<TextView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/darker_gray"
/>
<TextView
android:layout_weight="1"
android:layout_width="match_parent"