带有GridLayoutManger的行Recyclerview末尾的空白区域 [英] Empty spaces at the end of row Recyclerview with GridLayoutManger
问题描述
我将recyclerview
与gridlayoutmanger
一起使用,而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屋!