4

I am trying to use GridLayout with ImageViews. My problem is that the images I have are all different sizes. I have set the row count and column count, but somehow I need to set a fixed cell size (somehow uniform - as in cell width = total / num of columns, and cell height = total / num of rows). I want to do this so that when I set height and width of imageview to match_parent, the image view doesn't expand beyond the cell size and the layout looks uniform.

I need 5 rows and 3 columns. Can someone suggest how to do this ?

Jake
  • 16,329
  • 50
  • 126
  • 202

1 Answers1

5

I answered a similar question here. The theory is to use a wrapper layout for your cell and provide the margins that it needs to it. Then use the imageview inside this layout. Thus the outer layout acts as a container for your imageview and it will never go out of the bound of its parent.

Community
  • 1
  • 1
Illegal Argument
  • 10,090
  • 2
  • 44
  • 61