How can we made LinearLayout manager like this:
I also have checked Linear and Grid managers but it seems that in this case we need something new.
How can we made LinearLayout manager like this:
I also have checked Linear and Grid managers but it seems that in this case we need something new.
I found the same problem in this topic and just make it fit my question:
RecyclerView LayoutManager different span counts on different rows
We just create GridLayoutManager
and override method, then simplity set it in Recycler:
val layoutManager = GridLayoutManager(context, 2)
layoutManager.spanSizeLookup = object : SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
// 5 is the sum of items in one repeated section
when (position % 3) {
0 -> return 2
1, 2 -> return 1
}
throw IllegalStateException("internal error")
}
}
recycler.layoutManager = layoutManager