RecyclerView 添加 Header,
RecycleView 设置 LayoutManager 为 GridLayoutManger的 时候;
Header 要占用3行
val manager = GridLayoutManager(activity, 3)
binding.sleepList.layoutManager = manager
// span size for each position, and assign it to manager.spanSizeLookup.
manager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int) = when (position) {
0 -> 3
else -> 1
}
}