Empty spaces at the end of row Recyclerview with GridLayoutManger

喜夏-厌秋 提交于 2019-12-13 09:21:58

问题


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.


回答1:


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);

See this link https://github.com/google/flexbox-layout#flexboxlayoutmanager-within-recyclerview



来源:https://stackoverflow.com/questions/49690257/empty-spaces-at-the-end-of-row-recyclerview-with-gridlayoutmanger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!