views:

22

answers:

1

I have a table in XML which has 6 columns and 9 rows. Each cell is filled with exactly one ImageView, forming a 6x9 grid. The images inserted into each ImageView are strictly 48x48 pixels, making the whole thing 288px wide and 432px tall.

I want to insert a new image which is 96x96 pixels (taking up 2x2 cells), and I want it to automatically fill the neighbouring cells (or look like it does) so the layout is preserved.

I have been trying to use a combination of ImageView.setVisibility(GONE) on the neighbouring cells to 'delete' them (including their layout) then put the image in the top-left cell which would then size correctly, but am having trouble implementing it.

I suspect the answer has some combination of fill parent or wrap content, but I can't for the life of me figure it out.

Any help would be very greatly appreciated.

A: 

I've just had to do something similar with rendering a grid of hexes whose contents can be varying heights. My solution in the end was to use invisible anchors and then the actual ImageViews that contained the images anchored to the bottom left of these anchor objects. It all works flawlessly without any need for programmatic processing.

So you'd basically have a 6x9 grid of empty/black/invisible ImageViews which is purely for anchoring the next grid of 6x9 ImageViews which hold your actual images. That way if you want a 96x96 drawable in a tile, you just don't put anything in the overwritten tiles and everything else still just sits in the right place.

Zulaxia
sorry, I'm not entirely sure what you mean by anchoring? Could you give an example of what you speak of?
Dororo