问题
I Created a RecyclerView
And Set layoutManager
Of My Adapter To GridLayout
.
But I Want GridLayout
Like Instagram Search below image,
I Want A GridView
Like This :
Please Help Me . Thanks .
i tried SpanSizeLookup But i Have Still My Problem And i Cant Control My Items to laying out exactly that way . . .
回答1:
please take a look this answer
and for show Your list in Span
val manager = SpannedGridLayoutManager(object : SpannedGridLayoutManager.GridSpanLookup{
override fun getSpanInfo(position: Int): SpannedGridLayoutManager.SpanInfo {
// Conditions for 2x2 items
return if (position % 12 == 0 || position % 12 == 7) {
SpannedGridLayoutManager.SpanInfo(2, 2)
} else {
SpannedGridLayoutManager.SpanInfo(1, 1)
}
}
},3/*column*/,1f/*how big is default item*/)
binding.feedHome.setHasFixedSize(true)
binding.feedHome.layoutManager = manager
binding.feedHome.adapter = adapter
and this image help you how to calculate item in show big image
来源:https://stackoverflow.com/questions/56680985/implement-asymmetrical-grid-layout-manager-like-instagram-search