Android 中的自定义交错回收器视图
温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
I want to implement list of items. I want to implement this, as one of the section in my application. What is the correct way of implementing this in Android, I need a starting point. Is this possible with a recycler view? Please share any library or github project if available.
val lManager = StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
I tried below function to set view like this
private void setSpanValue() {
StaggeredGridLayoutManager staggeredGridLayoutManager;
if (modelArrayList.size() == 1) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else if (modelArrayList.size() == 2) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else if (modelArrayList.size() == 3) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else if (modelArrayList.size() == 4) {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
} else {
staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
}
recyclerView.setLayoutManager(staggeredGridLayoutManager);
recyclerView.hasFixedSize();
Adapter adapter = new Adapter(this, modelArrayList, checkEvenOrOdd(modelArrayList.size()));
recyclerView.setAdapter(adapter);}
Thank you in advance
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2333
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
热门推荐
-
浏览(192) 评论(0)