Issue
I need to center elements in each row so they will be like in this mockup. I've been searching if there is any layout that works that way without look. items are centered in their rows.
src="https://i.stack.imgur.com/w11fv.png]" alt="mockup">
This is how it looks now in my code.
Solution
Achieved with:
recyclerView.adapter = MyAdapter()
val layoutManager = FlexboxLayoutManager(context).apply {
justifyContent = JustifyContent.CENTER
alignItems = AlignItems.CENTER
flexDirection = FlexDirection.ROW
flexWrap = FlexWrap.WRAP
}
recyclerView.layoutManager = layoutManager
You need to add FlexboxLayout to your gradle:
implementation 'com.google.android.flexbox:flexbox:3.0.0'
Answered By - AskQ
Answer Checked By - Robin (JavaFixing Admin)