Updated 22 May 2017
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.
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); |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
6 comments