Empty spaces at the end of row Recyclerview with G

2019-10-03 04:37发布

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条回答
时光不老,我们不散
2楼-- · 2019-10-03 05:03

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

查看更多
登录 后发表回答