I`m new in Android. Could somebody help with "strange" StaggeredGridLayout behavior. GIFs attached below:
first_example_StaggeredGridLayout_behavior.gif
second_example_StaggeredGridLayout_behavior.gif
My recycler init code:
val layoutManager = StaggeredGridLayoutManager(resources.getInteger(R.integer.span_value), StaggeredGridLayoutManager.VERTICAL)
layoutManager.gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS
photoRecycler.adapter = adapterUnsplash
photoRecycler.layoutManager = layoutManager
photoRecycler.addItemDecoration(StaggeredItemDecoration(view.resources.getInteger(R.integer.column_spacing)))
ItemDecoration class
class StaggeredItemDecoration constructor(private var space: Int)
: RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) {
val halfSpacing = space / 2
outRect.set(halfSpacing, halfSpacing, halfSpacing, halfSpacing)
}
}
I've researched a lot of sources, but all didn`t help with my issue. Thanks in advance.