gridView with different cells sizes, pinterest style

假装没事ソ 提交于 2019-11-27 03:20:45

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);

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

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!