Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:57:58+00:00 2026-05-16T14:57:58+00:00

Been stuck on this for days, things just aren’t working with how I’m setting

  • 0

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 3×3 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.

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:57:58+00:00Added an answer on May 16, 2026 at 2:57 pm

    Finally got it working using RelativeLayout and anchors. Anchors are set to be the size of 1×1 grid square, then you have another set of image views AlignLeft and AlignTop on the position you want it e.g:

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/relay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"> 
    
        <ImageView android:id="@+id/a_t1"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
            />
        <ImageView android:id="@+id/a_t2"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t1"
            />
        <ImageView android:id="@+id/a_t3"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t2"
            />
        <ImageView android:id="@+id/a_t4"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t3"
            />
        <ImageView android:id="@+id/a_t5"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t4"
            />
    
    
            <ImageView android:id="@+id/a_t6"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_below="@id/a_t1"
            />
        <ImageView android:id="@+id/a_t7"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t6"
    android:layout_below="@id/a_t2"
            />
        <ImageView android:id="@+id/a_t8"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t7"
    android:layout_below="@id/a_t3"
            />
        <ImageView android:id="@+id/a_t9"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t8"
    android:layout_below="@id/a_t4"
            />
        <ImageView android:id="@+id/a_t10"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t9"
    android:layout_below="@id/a_t5"
            />
    
    
    
            <ImageView android:id="@+id/a_t11"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_below="@id/a_t6"
            />
        <ImageView android:id="@+id/a_t12"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t11"
    android:layout_below="@id/a_t7"
            />
        <ImageView android:id="@+id/a_t13"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t12"
    android:layout_below="@id/a_t8"
            />
        <ImageView android:id="@+id/a_t14"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t13"
    android:layout_below="@id/a_t9"
            />
        <ImageView android:id="@+id/a_t15"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t14"
    android:layout_below="@id/a_t10"
            />
    
    
    
    <ImageView android:id="@+id/a_t16"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_below="@id/a_t11"
            />
        <ImageView android:id="@+id/a_t17"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t16"
    android:layout_below="@id/a_t12"
            />
        <ImageView android:id="@+id/a_t18"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t17"
    android:layout_below="@id/a_t13"
            />
        <ImageView android:id="@+id/a_t19"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t18"
    android:layout_below="@id/a_t14"
            />
        <ImageView android:id="@+id/a_t20"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_toRightOf="@id/a_t19"
    android:layout_below="@id/a_t15"
            />
    
        <ImageView android:id="@+id/gs01"
            android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|left"
    android:layout_alignLeft="@id/a_t1"
    android:layout_alignTop="@id/a_t1"
            />
    
    </RelativeLayout>
    

    So if you want to put something on #2 like my example, change layout_alignLeft and layout_alignTop on id gs01 to be @id/a_t2, and it will work. This gets around the issue with putting setVisibility(GONE) which deletes the ‘anchor’ point used to calculate the position of the grid spaces.

    Now that was complicated. =(

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been stuck on this for days, and was wondering if anyone had
Why isn't this code working? I've been stuck on this for 2 days. public
I have been stuck on this for a few days now and it is
I have been stuck on this one for days, but I have broken it
I've been stuck on this for 3 days now. I have two pages that
I have been stuck on this for a few days and I would ping
I've been working with this for about 2 days now. I'm stuck, with a
I have been stuck on this problem for days and am about the crack...
Sorry for the long question, but I have been stuck on this for days
I have been stuck on this problem for almost 2 days now, consider the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.