Krishna
Krishna

Reputation: 4984

How to design the layout using relative layout?

In my android application I want to design the layout like blow

home

I have the four separate images like below

enter image description hereenter image description here

please anyone help me in this how to design this layout. Thanks in advance

Upvotes: 0

Views: 192

Answers (3)

Rajiv Ratan
Rajiv Ratan

Reputation: 129

To achieve this you need to have 5 set of image. One is default and other four will be like enter image description here

So onclick of the image you need to switch the image with animation.

Upvotes: 0

jignesh.world
jignesh.world

Reputation: 1446

You can try this..

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/image1" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/image2" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/image4" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/image3" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

Upvotes: 1

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

// try this
<?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:padding="5dp"
              android:orientation="vertical">

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

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:adjustViewBounds="true"
                    android:src="@drawable/ic_launcher"/>
        </LinearLayout>
        <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:adjustViewBounds="true"
                    android:src="@drawable/ic_launcher"/>
        </LinearLayout>

    </LinearLayout>

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

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:adjustViewBounds="true"
                    android:src="@drawable/ic_launcher"/>
        </LinearLayout>
        <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:adjustViewBounds="true"
                    android:src="@drawable/ic_launcher"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Upvotes: 0

Related Questions