带有GridLayoutManger的行Recyclerview末尾的空白区域 [英] Empty spaces at the end of row Recyclerview with GridLayoutManger

查看:116
本文介绍了带有GridLayoutManger的行Recyclerview末尾的空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将recyclerviewgridlayoutmanger一起使用,而spancount 2仅在recyclerview中包含固定的12个元素.在横向模式下的数位板中,第六个元素之后仍留有空白.我想用第二行的元素填充空白处.如果空间不足,则第一行包含6、7、8、9 ...元素,取决于剩余空间.

I am using recyclerview with gridlayoutmanger with spancount 2 containing fixed 12 elements only in recyclerview.On tablets in landscape mode the empty space is remaining after the sixth element. I want to fill the empty space with the elements from second row. If space is there than then first row contain either 6, 7, 8 ,9 ... elements depends upon the remaining space.

推荐答案

在回收站视图中使用FlexLayoutManger:

Use FlexLayoutManger with recycler view :

RecyclerView recyclerView = (RecyclerView) context.findViewById(R.id.recyclerview);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.COLUMN);
layoutManager.setJustifyContent(JustifyContent.FLEX_END);
recyclerView.setLayoutManager(layoutManager);

查看此链接 https://github.com/google/flexbox-layout#flexboxlayoutmanager-within- recyclerview

这篇关于带有GridLayoutManger的行Recyclerview末尾的空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆