1

I am trying to create a Windows like tile structure for my app. Below is my XML file.
The problem is that I cannot get the 'Cat' image to fit in the gap.

http://www.tiikoni.com/tis/view/?id=b9a264b

That is to say, filling the screen with unequal ImageViews. Please help.

<ScrollView 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:background="#31352e" >

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

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:layout_margin="5dp"
            android:src="@drawable/xxx"
            android:scaleType="fitXY"/>
        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:orientation="horizontal">
            <ImageView
               android:id="@+id/imageView2"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:padding="3dp"
                android:scaleType="fitXY"
                android:src="@drawable/dog1" />

             <ImageView
                android:id="@+id/imageView3"
                android:layout_width="200dp"
                android:layout_height="250dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="3dp"
                android:scaleType="fitXY"
                android:src="@drawable/dog" />


        </LinearLayout>>
       <RelativeLayout
           android:layout_width="200dp"
           android:layout_height="180dp">
        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="200dp"
            android:layout_height="150dp"
            android:layout_margin="5dp"
            android:background="#fff"
            android:padding="3dp"
            android:scaleType="fitXY"
            android:src="@drawable/cat"
            android:layout_below="@+id/imageView2"/>
    </RelativeLayout>>
    </LinearLayout>

</ScrollView>

Didn't allow me to attach snapshot. :(

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Akhil
  • 11
  • 1

1 Answers1

0

If you are not using GridLayout, then you should use Linear Layout this way:

 -----------------
| ------   ------ |
|| ---- | | ---- ||
||| p1 || ||    |||
|| ---- | || p2 |||
|| ---- | | ---- ||
|||    || |Layout||
||| p3 ||  ------ |
|| ---- |         |
||Layout|         |
| ------   Layout |
 -----------------

you should have a horizontal linear layout wrap around 2 vertical linear layout so that the screen is divided into left and right 2 parts. This should looks more like what are you trying to do.

code:

<ScrollView 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:background="#31352e" >

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

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="150dp"
        android:layout_margin="5dp"
        android:src="@drawable/ic_launcher"
        android:scaleType="fitXY"/>
    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:orientation="vertical">
            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:padding="3dp"
                android:scaleType="fitXY"
                android:src="@drawable/ic_launcher" />



            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:padding="3dp"
                android:scaleType="fitXY"
                android:src="@drawable/ic_launcher"
                android:layout_below="@+id/imageView"/>

        </LinearLayout>

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

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="200dp"
                android:layout_height="250dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="3dp"
                android:scaleType="fitXY"
                android:src="@drawable/ic_launcher" />



        </LinearLayout>






    </LinearLayout>
</LinearLayout>

kaho
  • 4,746
  • 1
  • 16
  • 24