Center RecyclerView items with FlexboxLayoutManager

3

I'm using FlexboxLayoutManager to align items, however, I need all items to be aligned in the center, regardless of the amount of items (dynamically).

I want these items to look like this:

ButwhatIdidlookslikethis:

(I want yo-yo to stay in the center)

How do I define layoutmanager:

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 use layoutManager.setAlignItems(AlignItems.CENTER) but it does not work

    
asked by anonymous 15.05.2018 / 18:32

1 answer

0

Would not that be just not it?

layoutManager.setAlignItems(AlignItems.CENTER)

or

layoutManager.setJustifyContent(AlignItems.CENTER)

Source: link

    
17.05.2018 / 21:43