user4748790
user4748790

Reputation:

Android 3 columns design

I need to develop a landscape design of 3 columns.

The left and right will have a specific size, preferably a percentage of the available width, say 10% each.

The middle one need to take the remaining 80% percent of the screen.

Which is the best approach for developing it? My code is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"

android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:background="@drawable/background">



<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="10">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="7">


        <LinearLayout
            android:orientation="vertical"
            android:layout_height="match_parent"
            android:layout_width="100dp"
            android:layout_gravity="left"
            android:layout_weight="0.2">

            ...

        </LinearLayout>

        <GridLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:columnCount="7"
            android:rowCount="4"
            android:layout_gravity="center"
            android:layout_weight="0.6">

          ...

        </GridLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="100dp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:layout_weight="0.2">

            .....

        </LinearLayout>


    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="90">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/offer_taken"
            android:layout_weight="1"
            android:text="gfhfg hg" />
    </LinearLayout>
</LinearLayout>

Upvotes: 0

Views: 50

Answers (1)

Abhishek Jaiswal
Abhishek Jaiswal

Reputation: 628

You can do similar like this

<LinearLayout  
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:screenOrientation="landscape"
android:weightSum="10"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">


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

    ....

</LinearLayout>

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="8">

    ....

</LinearLayout>

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

    ....

</LinearLayout>


</LinearLayout>

Upvotes: 1

Related Questions