需要帮助来创建布局

时间:2012-03-15 06:48:57

标签: android layout

我尝试创建这种类型的布局

enter image description here

但是我不能这样,这是我的观点

enter image description here

这是我创建布局的代码

<?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:background="#ffffff"
    android:orientation="vertical" 
    android:weightSum="1">

    <TextView
        android:id="@+id/app_title_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="5dp"
        android:text="Stuffs on the go lite"
        android:textColor="#000"
        android:textSize="18dp" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/app_title_view"
        android:orientation="horizontal" android:gravity="center">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" 
            android:background="#29000000"
            android:padding="10dp" android:weightSum="1">

            <TextView
                android:id="@+id/all_stuff_view"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="0.5"
                android:background="#959686"
                android:gravity="center"
                android:padding="10dp"
                android:text="All Stuffs"
                android:textColor="#000"
                android:textSize="16dp" />

            <TextView
                android:layout_weight="0.5"
                android:id="@+id/setting_view"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#441244"
                android:gravity="center"
                android:padding="10dp"
                android:text="Map"
                android:textColor="#000"
                android:textSize="16dp" 
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:orientation="vertical" android:background="#29000000"
            android:padding="10dp" android:weightSum="1">

            <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:orientation="horizontal" android:background="#92000000" android:layout_weight="0.5">

                <TextView android:id="@+id/setting_view" android:layout_width="fill_parent"
                    android:layout_height="fill_parent" android:layout_weight="0.5"
                    android:background="#441244" android:gravity="center"
                    android:padding="10dp" android:text="Memo"
                    android:textColor="#000" android:textSize="16dp" />

                <TextView android:id="@+id/all_stuff_view" android:layout_width="fill_parent"
                    android:layout_height="fill_parent" android:layout_weight="0.5"
                    android:background="#959686" android:gravity="center"
                    android:padding="10dp" android:text="Task"
                    android:textColor="#000" android:textSize="16dp" />
            </LinearLayout>
            <TextView android:id="@+id/all_stuff_view" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:layout_weight="0.5"
                android:background="#959686" android:gravity="center"
                android:padding="10dp" android:text="Reminder"
                android:textColor="#000" android:textSize="16dp" />
            <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#92000000">
            <TextView
                android:id="@+id/all_stuff_view"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="0.5"
                android:background="#959686"
                android:gravity="center"
                android:padding="10dp"
                android:text="Setting"
                android:textColor="#000"
                android:textSize="16dp" />
        </LinearLayout>
        </LinearLayout>

    </LinearLayout>
</LinearLayout>

感谢您的帮助和建议

6 个答案:

答案 0 :(得分:0)

我认为最好使用表格布局并根据需要合并行和列。考虑一下。

我希望它可以帮助你。

答案 1 :(得分:0)

你可以在LinearLayout中使用一些RelativeLayout来管理它

答案 2 :(得分:0)

这是你的XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/titlelayout"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:gravity="center_vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="realplayer" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/arrow" />
</RelativeLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/titlelayout"
    android:orientation="vertical"
    android:weightSum="2" >

    <LinearLayout
        android:id="@+id/toplayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:weightSum="2" >

        <LinearLayout
            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="playlists" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:weightSum="2" >

                <LinearLayout
                    android:id="@+id/toprighttoplayout"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:weightSum="2" >

                    <LinearLayout
                        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="artist" />
                    </LinearLayout>

                    <LinearLayout
                        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="Albums" />
                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/toprightbottomlayout"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:weightSum="2" >

                    <LinearLayout
                        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="genres" />
                    </LinearLayout>

                    <LinearLayout
                        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="songs" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottomlayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:weightSum="2" >

        <LinearLayout
            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="videos" />
        </LinearLayout>

        <LinearLayout
            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="photos" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

答案 3 :(得分:0)

您可以使用以下布局实现此目的。只需查找 TextView 项目即可找到框位置。只需复制粘贴以下布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="2">

    <!-- first half of screen -->
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#DEB887">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:weightSum="2">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#1E90FF">

                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-1"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#FF69B4">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:weightSum="2">

                    <LinearLayout 
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="#DEB887">

                        <LinearLayout
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:weightSum="2">
                            <LinearLayout
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:layout_weight="1"
                                android:background="#8FBC8F">

                                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-2"/>

                            </LinearLayout>

                            <LinearLayout
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:layout_weight="1"
                                android:background="#F0E68C">

                                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-3"/>

                            </LinearLayout>
                        </LinearLayout>

                    </LinearLayout>


                    <LinearLayout 
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="#F5F5DC">

                        <LinearLayout
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:weightSum="2">
                            <LinearLayout
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:layout_weight="1"
                                android:background="#F0E68C">

                                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-4"/>

                            </LinearLayout>

                            <LinearLayout
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:layout_weight="1"
                                android:background="#8FBC8F">

                                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-5"/>

                            </LinearLayout>
                        </LinearLayout>

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>
        </LinearLayout>

    </LinearLayout>


    <!-- second half of screen -->
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#F5F5DC">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:weightSum="2">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#FF69B4">

                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-6"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#1E90FF">

                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Box-7"/>

            </LinearLayout>
        </LinearLayout>

    </LinearLayout>


</LinearLayout>

答案 4 :(得分:0)

更新:删除屏幕截图

这是xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:background="#123456"
    android:gravity="center"
    android:text="this title" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:orientation="vertical"
    android:weightSum="2" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#00ff00"
        android:orientation="horizontal"
        android:weightSum="2" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#654321" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#0000ff"
            android:orientation="vertical"
            android:weightSum="2" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#454545"
                android:orientation="horizontal"
                android:weightSum="2" >

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="#143434" >
                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="#564456" >
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#765245"
                android:orientation="horizontal"
                android:weightSum="2" >

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="#878987" >
                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:background="#213556" >
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#0000ff"
        android:weightSum="2" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#675678" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#989763" >
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

答案 5 :(得分:0)

HI I have generated this layout for example:

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

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:background="#eee"
        android:layout_height="wrap_content" >
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center|center"
android:gravity="center|center"
android:orientation="vertical" >
        <ImageView android:background="@drawable/ic_launcher"
         android:layout_width="wrap_content"

         android:layout_height="wrap_content"   
        />
        </LinearLayout>
           <TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_gravity="center|center"
        android:background="#feedae"
        android:layout_height="wrap_content" >

        <ImageView android:background="@drawable/ic_launcher"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"   
        />
        <ImageView android:background="@drawable/ic_launcher"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"   
        />
        </TableRow>
          <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_gravity="center|center"
        android:background="#feedae"
        android:layout_height="wrap_content" >

        <ImageView android:background="@drawable/ic_launcher"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"   
        />
        <ImageView android:background="@drawable/ic_launcher"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"   
        />
        </TableRow>
    </TableLayout>    

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </TableRow>
</TableLayout>