Android StaggeredGridLayoutManager offset bug

我的梦境 提交于 2019-12-04 12:18:33

问题


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


来源:https://stackoverflow.com/questions/33126960/android-staggeredgridlayoutmanager-offset-bug

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