android的线性布局

计应111 杨惠

线性布局中有两个重要的属性:

布局的代码如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:orientation="vertical" android:layout_height="fill_parent">

    <LinearLayout

        android:id="@+id/linearLayout1"

        android:layout_width="match_parent"

        android:layout_height="0px"

        android:layout_weight="1"

        android:orientation="horizontal" android:background="#ff00ff">//布局方式,横向排列

        <TextView

            android:id="@+id/textView1"

            android:layout_width="0px"

            android:layout_height="fill_parent"

            android:text="TextView" android:background="#ff0000" android:layout_weight="1"/>

        <TextView

            android:id="@+id/textView2"

            android:layout_width="0px"

            android:layout_height="fill_parent"

            android:text="TextView" android:background="#f0f0f0" android:layout_weight="1"/>

        <TextView

            android:id="@+id/textView3"

            android:layout_width="0px"

            android:layout_height="fill_parent"

            android:text="TextView" android:background="#3f3f3f" android:layout_weight="1"/>

        <TextView

            android:id="@+id/textView4"

            android:layout_width="0px"

            android:layout_height="fill_parent"

            android:text="TextView" android:background="#6f6f6f" android:layout_weight="1"/>

    </LinearLayout>

    <LinearLayout

        android:id="@+id/linearLayout2"

        android:layout_width="match_parent"

        android:layout_height="0px"

        android:orientation="vertical" android:layout_weight="1" android:background="#00ff00">//布局方式,纵向排列

        <TextView

            android:id="@+id/textView5"

            android:layout_width="fill_parent"

            android:layout_height="0px"

            android:text="TextView" android:layout_weight="1" android:background="#00ff00"/>

        <TextView

            android:id="@+id/textView6"

            android:layout_width="fill_parent"

            android:layout_height="0px"

            android:text="TextView" android:background="#454545" android:layout_weight="1"/>

        <TextView

            android:id="@+id/textView7"

            android:layout_width="fill_parent"

            android:layout_height="0px"

            android:text="TextView" android:layout_weight="1" android:background="#0f0f00"/>

        <TextView

            android:id="@+id/textView8"

            android:layout_width="fill_parent"

            android:layout_height="0px" 

           android:text="TextView" android:background="#ff0000" android:layout_weight="1"/>

    </LinearLayout>

</LinearLayout>

实现的框架如下:

posted on 2013-05-19 22:39  bulaiyou  阅读(103)  评论(0编辑  收藏  举报