Android StaggeredGridLayoutManager offset bug

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

When you clear your adapter and call notifyDataSetChanged() - StaggedGridLayoutManager manager still has mCachedStart/End in Span[] instances. So when you add new items to adapter - layout manager draws items with offset, and this is a huge problem.

EtsyStaggeredGridView has method resetToTop() which clears all cached stuff and draws everything from scratch.

There are some workarounds:

  • Call layoutManager.onDetachedFromWindow(recyclerView, null) after clearing an adapter
  • Set new layout manager which is bad

回答1:

There are some workarounds:

  • Call layoutManager.onDetachedFromWindow(recyclerView, null) after clearing an adapter
  • Set new layout manager which is bad


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!