Centralize Recyclerview Items with Flexboxlayoutmanager

Asked

Viewed 180 times

3

I’m using Flexboxlayoutmanager to align the items, but I need all items to be aligned in the center, regardless of the amount of items (dynamically).

I want these items to stay like this: inserir a descrição da imagem aqui

But what I’ve done stays that way:

inserir a descrição da imagem aqui

(I want the yo-yo to stay downtown)

How I defined the 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 doesn’t work

1 answer

0

  • I tried, it didn’t work

Browser other questions tagged

You are not signed in. Login or sign up in order to post.