I want a RecyclerView.LayoutManager
that allows me to specify different span counts for different rows as a repeating pattern. For example 2,3 with 10 items wou
here's how to do it in kotlin:
val layoutManager= GridLayoutManager(activity, 3)
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return when (position) {
0 -> 3
else -> 1
}
}
}
recyclerView.layoutManager = layoutManager
here, first we have created a grid layout manager with 3 columns, then we have specified the first will occupy the whole 3 columns while the rest take only one.