实验三UI线性布局管理器
- 实验名称
UI线性布局管理器
- 实验目的:
熟悉UI线性布局管理器
- 实验环境:
Windows xp+,jdk-6u32-windows-i586,adt-bundle-windows-x86-*。
- 实验结果:
- 主界面显示
图 4-1-1 主界面显示
- 参考代码:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<LinearLayout
android:id="@+id/lay1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0066"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#33ff00"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_below="@id/lay1"
>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#0033cc"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#990000"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#ff66cc"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#993399"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#666699"
android:layout_weight="1"
/>
</LinearLayout>
- 实验总结:
通过本次实验,我熟悉了UI线性布局管理器。学会了宽度,高度和背景颜色的设置。复杂的布局还需要进一步学习。