GridView is a class that extends AdapterView , which means it shows cells in a grid-style efficiently, recycling old views to be shown as new ones when
I think a RecyclerView with StaggeredGridLayoutManager can solve this issue, and that if you wish to also have a fast-scroller, you can try this library.
So, no more trick are needed, as Google provided a solution...
Is it a bit late to answer?
check this library from etsy. it looks very promising.
https://github.com/etsy/AndroidStaggeredGrid
I think it is newer version of https://github.com/maurycyw/StaggeredGridView
.
Updated.
Try using RecyclerView StaggeredGridLayoutManager from google instead
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
You may be able to accomplish this with a single ListView, where each cell contains a different grid template. I've done something similar to what you're describing, using this technique. If cell sizes need to be unique, this won't work, but it should be sufficient for the case you described:
AABB
AACC
AADD
AADD
Creating a handful of templates like this, with various arrangements of A,B,C,D, you can then randomly use them as ListView cells and some simple offset math would allow your adapter to populate each subcell to accomplish something like the following:
AABB
AACC
AADD
AADD
BBBB
ACCC
ADDD
ADDD
AAAA
BBCC
BBCC
DDDD
AABB
AACC
AADD
AADD
AABB
AACC
DDDD
DDDD