Как реализовать этот макет? - PullRequest
2 голосов
/ 01 июля 2011

Я хотел бы разделить мой текущий вид на 4 области (не делить экран на 4, а разделить вид) следующим образом:

Я хотел бы иметь макет следующего размера для вида:

enter image description here

Это по горизонтали , разделенное на половину вида для каждого.по вертикали верхняя область имеет 1/3 высоту вида, а две нижние области имеют 2/3 высоту вида.

Я успешно разделил мой вид на 4 равные по размеру области на:

<?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:id="@+id/top_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="horizontal"


    >
        <LinearLayout
            android:id="@+id/top_left_area"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/content_blue_bg"
            >
            <TextView

                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="TOP LEFT"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/top_right_area"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/content_blue_bg"
            >
            <TextView

                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="TOP RIGHT"/>
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"    
        android:orientation="horizontal"
        >

        <LinearLayout
            android:id="@+id/bottom_left_area"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"

            >

                <TextView 
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:text="BOTTOM LEFT"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/bottom_right_area"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/content_blue_bg"
            >
            <TextView

                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="BOTTOM RIGHT"/>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

Но как я могу получить высоту 1/3 для областей вверх и2/3 высоты обзора для нижних участков?

Ответы [ 2 ]

3 голосов
/ 01 июля 2011
 <?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:id="@+id/top_area"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:orientation="horizontal"
>
    <LinearLayout
        android:id="@+id/top_left_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/content_blue_bg"
        >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="TOP LEFT"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/top_right_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/content_blue_bg"
        >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="TOP RIGHT"/>
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:id="@+id/bottom_area"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="2"    
    android:orientation="horizontal"
    >
    <LinearLayout
        android:id="@+id/bottom_left_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        >

            <TextView 
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:text="BOTTOM LEFT"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom_right_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/content_blue_bg"
        >
        <TextView

            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="BOTTOM RIGHT"/>
    </LinearLayout>
</LinearLayout>

Все, что вам не хватало, это установить нижний макет на 70%, а верхний макет на 30%

Это было только что опубликовано в моем Twitter http://blog.stylingandroid.com/archives/297: -)

1 голос
/ 01 июля 2011

просто измените android:layout_weight для bottom_area LinearLayout на 2 вместо 1

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...