Been stuck on this for days, things just aren't working with how I'm setting this up. I have a large grid of ImageViews which are all the same size. It's made up of a Horizontal LinearLayout and within that, 5 Vertical LinearLayouts (first picture).
What I want (and I don't care how, be it using RelativeLayout, Linear or Tables) is if I were to set say Image #2 to a larger image (specifically 3x3 of the smaller ones) I want it to effectively 'overwrite' those images (as shown in picture 2).
I've tried doing this by setting the 'overwritten' images (3,4,7,8,9,12,13,14) to setVisibility(GONE) which works fine but then the second vertical LinearLayout has expanded to fit the size of the new image which I don't want. If I try setting it to fill_parent though it squashes the size of the image. As a result, what I get is the third picture.
All associated XML code (id codes match those on the image):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView android:id="@+id/gs05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
<ImageView android:id="@+id/gs20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
/>
</LinearLayout>
</LinearLayout>
If I were to do this using RelativeLayouts, I run into problems when I setVisibility(GONE) since the position may very well be referenced using a missing View. Setting it to INVISIBLE just leaves a blank space, when what I really want is effectively it to be of 0px by 0px in size.
Any help at all would be appreciated; it seems no matter what I try something always goes slightly wrong with it, and it's driving me insane.