StaggeredGridLayoutManager dislocation

China☆狼群 提交于 2019-12-06 10:57:45

try this?

staggeredGridLayoutManager..setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS)

StaggeredGridLayoutManager uses two strategies to deal with gaps. The default strategy is GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS, which means that StaggeredGridLayoutManager can rearrange your items. In your case you can use GAP_HANDLING_NONE to prevent rearranging. For example:

recyclerView.layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL).apply {
            gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!