RecyclerView item with collection of images

时间:2016-08-31 12:30:13

标签: android imageview android-recyclerview image-gallery

I'm tring to make some like RecyclerView list item image grid. It's has one main big image and some with other sizes. I've idea to use some like other holders for each image count, and choose it in adapter onCreateViewHolder method. But, I think, isn't good idea. Maybe you know some libraries or know some good practice examples?

image gallety container

1 个答案:

答案 0 :(得分:0)

您可以使用GridLayoutManager和自定义SpanSizeLookup执行此操作。

GridLayoutManager使您能够通过创建SpanSizeLookup来说明您希望特定项目跨越多少列(行)。代码如下所示:

    // Create a grid layout with four columns
    GridLayoutManager layoutManager = new GridLayoutManager(this, 4);

    // Create a custom SpanSizeLookup where the first item spans all four columns
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position == 0 ? 4 : 1;
        }
    });