In this blog, We have shown you how to make custom layout manager to make the different span count at the different row in recycler view.
Here, we will show the 2,2,4,4 span count on different columns.
Different span count at different row
Step 1: make custom adapter,
1 2 3 4 5 6 7 8 9 10 11 |
GridLayoutManager layoutManager = new GridLayoutManager(this, 4); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { if (position > 3) return 1; else return 2; } }); |
Step 2: apply to the recycler view,
1 |
((RecyclerView) childProduct.findViewById(R.id.category_product_rv)).setLayoutManager(layoutManager); |