android - RecyclerView LayoutManager“一二一”作为Sololearn的关卡菜单
解决方案
我在这个主题中发现了同样的问题,只是让它适合我的问题:
RecyclerView LayoutManager 不同行上的不同跨度计数
我们只需创建GridLayoutManager
和覆盖方法,然后在 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
推荐阅读
- ruby - 如何从 Watir cookie 生成 cookie 文件
- javascript - vue如何在关注画布后做出动作
- label - 组织模式 LaTeX 导出和子树
- c# - #nullable disable - 仅适用于特定命名空间?
- amazon-web-services - AWS Cloudformation:如何检查 Cloudformation 模板中是否存在存储桶?
- angular - 如何显示商店的内容?
- filter - tcpdump 过滤掉 arp 和所有 stp 数据包
- javascript - 单击单选按钮后如何清除文本输入?
- c - 不使用标志变量的数字的素数?
- python-3.x - 无法为 python3 链接 urllib 和 web3.py