6

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

enter image description here

I try with StaggeredGridLayoutManager but it must specify the number of column want the column take as screen size any help will be good

Ahmed Abdelmeged
  • 2,299
  • 2
  • 18
  • 29

2 Answers2

10

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

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
-1

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