Android:LinearLayout佈局和其嵌套運用舉例

 

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

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>


 

發佈了46 篇原創文章 · 獲贊 5 · 訪問量 29萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章