Android kotlin - RecyclerView StaggeredGridLayoutManager 2 columns too many items on one side

Viewed 714

I made a recyclerView with 2 columns with different height items.

This is the code:

            adapterMemes = MemesAdapterProfile(this@Profile, "latest", memes!!, "") {
                // toProfileToplist(it.userid.toString())
            }

            val layoutManagerMemes = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)


            recyclerViewProfile.adapter = adapterMemes
            recyclerViewProfile.layoutManager = layoutManagerMemes
            recyclerViewProfile.setHasFixedSize(true)

The problem is that the item count is not equal, for example it's 11 items on left side and 18 on right side so on the right side it ends up being much longer

I tried to add this layoutManagerMemes.gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE based on the answer here:

StaggeredGridLayoutManager: Adding Margin makes the layout items pushed to the side

but then the items't didn't show up any more.

Any ideas?

0 Answers
Related