How do I center all my RecyclerView
items using the FlexboxLayoutManager
?
I need the items to be centered like this:
My code where I set the layout manager:
val layoutManager = FlexboxLayoutManager(this)
layoutManager.setFlexWrap(FlexWrap.WRAP)
layoutManager.setFlexDirection(FlexDirection.ROW)
layoutManager.setJustifyContent(JustifyContent.FLEX_START)
layoutManager.setAlignItems(AlignItems.FLEX_START)
val adapter = TagAdapter(tags)
tagRecyclerView.adapter = adapter
tagRecyclerView.layoutManager = layoutManager
(I tried to set layoutManager.setAlignItems(AlignItems.FLEX_START
) to layoutManager.setAlignItems(AlignItems.CENTER)
however it did not work...
Try this