I am trying to do this using recycler view with gridlayoutmanager. GridLayoutmanager takes spancount. Here I want to update the view based on the width of the text in the recycler view items.
Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts for the various screen sizes.
GridLayoutManager is used for displaying the data items in grid format and we can easily define the orientation for the items.
Android GridLayoutManager is the RecyclerView. LayoutManager implementation to lay out items in a grid. In this tutorial, we'll create an application that displays CardViews inside a RecyclerView in the form of a GridLayout.
It's a late answer but I wanted to achieve exactly the same stuff!
Then after several hours of research, I found this lib (I don't know why I didn't find it earlier...) by Google: FlexboxLayout who has a FlexboxLayoutManager
!
How to use:
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection = FlexDirection.ROW
myRecyclerView.layoutManager = layoutManager
That's all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With