Android:LinearLayout布局和其嵌套运用举例

来源:互联网 发布:女主播直播软件 编辑:程序博客网 时间:2024/06/07 17:21

 

==========================

main.xml

                         看mars老师的视频学习安卓里面的布局部分,做的样例,显摆一下,全部都是在main.xml里面配置的。

==========================

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:layout_weight="1"        android:orientation="horizontal" >        <TextView            android:layout_width="wrap_content"            android:layout_height="fill_parent"            android:layout_weight="1"            android:background="#0000aa"            android:gravity="center_vertical"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="wrap_content"            android:layout_height="fill_parent"            android:layout_weight="1"            android:background="#00aa00"            android:gravity="center_vertical"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="wrap_content"            android:layout_height="fill_parent"            android:layout_weight="1"            android:background="#0000aa"            android:gravity="center_vertical"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="wrap_content"            android:layout_height="fill_parent"            android:layout_weight="1"            android:background="#00aa00"            android:gravity="center_vertical"            android:text="@string/hello"            android:textSize="30dp" />    </LinearLayout>    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:layout_weight="1"        android:orientation="vertical" >        <TextView            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_weight="1"            android:background="#00aa00"            android:gravity="center_horizontal"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_weight="1"            android:background="#0000aa"            android:gravity="center_horizontal"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_weight="1"            android:background="#00aa00"            android:gravity="center_horizontal"            android:text="@string/hello"            android:textSize="30dp" />        <TextView            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_weight="1"            android:background="#0000aa"            android:gravity="center_horizontal"            android:text="@string/hello"            android:textSize="30dp" />    </LinearLayout></LinearLayout>