Как я могу упростить мой макет? - PullRequest
1 голос
/ 27 февраля 2012

Я начинающий разработчик, я создал макет, который соответствует моим ожиданиям, но я боюсь, что его конструкция слишком сложна.

Я использовал много макетов, но я не вижу, как построить похожий макет, не смешивая линейные и относительные макеты, это возможно?

Как я могу упростить этот макет? Спасибо за ваши идеи.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >

<LinearLayout
    android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/black_blue_gradient"
    android:paddingBottom="5dip"
    android:paddingTop="24dip" >
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/header" >

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

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:id="@+id/footer"
                android:layout_width="fill_parent"
                android:layout_height="8dp"
                android:layout_alignParentBottom="true"
                android:background="@drawable/b_bgradient" >
            </LinearLayout>

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/footer"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:src="@drawable/oranwall_ovosh" />
        </RelativeLayout>
    </LinearLayout>

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#E9EEF2"
            android:gravity="center_vertical|center_horizontal"
            android:text="@string/My_txt"
            android:textColor="#535A5F"
            android:textSize="14sp" />
    </LinearLayout>
</LinearLayout>

</RelativeLayout>

Ответы [ 2 ]

2 голосов
/ 27 февраля 2012

Попробуй. Не забудьте поставить свой фон и другие ресурсы

     <?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" >

    <TableRow
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:background="@drawable/ic_launcher">
    </TableRow>

    <TableRow
        android:id="@+id/body"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:layout_weight="3">

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <LinearLayout
                android:id="@+id/linearLayout2"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:src="@drawable/perm" />

                <TableRow
                    android:id="@+id/footer"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.5"
                    android:background="@drawable/ic_launcher" >
                </TableRow>

            </LinearLayout>

        </LinearLayout>

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </TableRow>

</LinearLayout>
1 голос
/ 27 февраля 2012

Я бы сделал несколько изменений:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

    <!-- I don't understand the point of this one: -->
    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/black_blue_gradient"
        android:paddingBottom="5dip"
        android:paddingTop="24dip" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >

        <LinearLayout
            android:id="@+id/linearlayout01left"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="0.4"
            android:orientation="horizontal" >

            <RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <!-- I don't understand the point of this one -->
                <LinearLayout
                    android:id="@+id/footer"
                    android:layout_width="match_parent"
                    android:layout_height="8dp"
                    android:layout_alignParentBottom="true"
                    android:background="@drawable/b_bgradient" >
                </LinearLayout>

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/footer"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:src="@drawable/oranwall_ovosh" />
            </RelativeLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearlayout02right"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="0.6"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="#E9EEF2"
                android:gravity="center_vertical|center_horizontal"
                android:text="@string/My_txt"
                android:textColor="#535A5F"
                android:textSize="14sp" />
        </LinearLayout>
    </LinearLayout>

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