Reputation: 2419
hi i want to make a recycler view to take items horizontal as many as the screen fit but with vertical scroll like this image as example
I try with StaggeredGridLayoutManager
but it must specify the number of column want the column take as screen size any help will be good
Upvotes: 6
Views: 5500
Reputation: 5370
You can use FlexLayoutManager
for this kind of design FlexLayout
Here is a example snippet to use FlexLayoutManager
in RecycleView
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);
Their are many attributes to use FlexLayout
Go through the documents on github
Upvotes: 10
Reputation: 1026
As Burhanuddin Rashid commented, you should use the FlexBoxLayout. It has a LayoutManager for RecyclerViews, so the additional code will be minimal. https://github.com/google/flexbox-layout#flexboxlayoutmanager-within-recyclerview
Upvotes: -1