Need help creating a layout

I tried to create this type of layout

enter image description here

but i can't look like that, here's my look

enter image description here

and here is my code for creating the layout

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

      

Your help and suggestion is appreciated thanks to you

+3


source to share


6 answers


update: take screenshot

here is the xml layout:



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

      

0


source


I think it is better to use Table Layout with concatenation of rows and columns as needed. Just think about it.



I hope this can help you.

0


source


you can use RelativeLayout in LinearLayout to control it

0


source


Here is your 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>

      

0


source


You can achieve this with the following layout. Just search for TextView items to find the positions in the box. Just copy paste the following layout:

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

      

0


source


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>

      

0


source







All Articles