Android佈局 平分界面

之前作iOS的,android水平屬於渣渣如下,如今作界面都感受是在吃糠,寫一段查半天。心累到不想說話。android

今天主要是遇到界面上三個空間並排排列,平分界面,其實就是和支付寶下面那些選項卡同樣。.net

不講中間的坑了,直接上結果:code

設置參數:layout_weight = 1;xml

一個LeanerLayout裏面的控件都把layout_weight設同樣的就能夠實現平分,LeanerLayourt是水平的就水平平分,豎直的就豎直平分。blog

示例:支付寶

<!-- 一堆框框 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/y360"
        android:orientation="horizontal"
        android:background="@color/actionsheet_red">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_height="match_parent">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="sssssssss"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal"
            android:layout_height="match_parent">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="vvvvvvvvvvv"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_height="match_parent">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="sssssssss"/>
        </LinearLayout>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/y360"
        android:orientation="horizontal"
        android:background="@color/black">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_height="@dimen/y360">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="sssssssss"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="@dimen/y360">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="vvvvvvvvvvv"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_height="@dimen/y360">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="sssssssss"/>
        </LinearLayout>

    </LinearLayout>

 

更詳細的參考下面連接:http://blog.csdn.net/chy800/article/details/46397927it

相關文章
相關標籤/搜索