Reputation: 1263
Is there any way to get a RecyclerView with different spanCount for every row depends on how many items can fit in a row ? Meaning when there is no more width to fit new item, it will break into a new row.
I've attached a photo so you can see what I need.
If can't be done with RecyclerView, can it be done with TableLayout ? or a listView ?
Upvotes: 1
Views: 628
Reputation: 189
You can use ChipsLayoutManager also. https://github.com/BelooS/ChipsLayoutManager
implementation'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
allprojects {
repositories {
jcenter()
}
}
Upvotes: 0
Reputation: 1511
The solution is FlexLayoutManager:
https://github.com/google/flexbox-layout
All you need to do is to add it in Gradle (1.1.0 for project using AndroidX artifacts, 1.0.0 other way):
implementation("com.google.android:flexbox:1.1.0")
And create it like this:
recycler.layoutManager = FlexboxLayoutManager(context, FlexDirection.ROW)
Upvotes: 0
Reputation: 3916
You can do this with a Recycler View and a custom Layout Manager
This article might help http://wiresareobsolete.com/2014/09/building-a-recyclerview-layoutmanager-part-1/
(sorry I don't have code to share. ive never done this, but i think its possible to do accomplish it this way)
Upvotes: 1