Meryl
Meryl

Reputation: 193

Android layout - custom grid like layout

I am trying to find solution how to display images in 2 columns grid with first row need to be one element with two columns width.

Android customize first child of grid view

I found this. but I hope there is some better solution...

Upvotes: 0

Views: 320

Answers (1)

Sami Eltamawy
Sami Eltamawy

Reputation: 10009

You can do it using FrameLayout. This kind of layout allow you to put more than one Layout or XML item above each other.

I recommend for you to use the FrameLayout as a parent layout. Inside it put two GridViews the first one will represent the first wide element. The second GridView will be the normal small elements.

Put into your first GridView with your specific XML properties (Double wider than the others) only one item. Put into your first GridView with your specific XML properties the rest of items.

When you are handling the actions or the filling of the second GridView neglect the first two positions (Position 0 and 1) then act normal for the other.

Here is a good example of the FrameLayout usage. And here is a simple example of the GridView usage. I hope it helps

Upvotes: 1

Related Questions