Is there a way to share a same LayoutManager between multiple nested RecyclerViews

旧巷老猫 提交于 2019-12-04 08:01:14

By now, I used GridLayout instead of the nested RecyclerView, and recycling views which inside those GridLayout myself. But it is probably not a good way because my recycling logical was very simplicity. The application still a little bit stutter while fast scrolling, I haven't figure it out. As a viable ending, I push my code in github. Please advising me if you have ideas, thanks.

Yes, what you are doing is right.

Just create a RecyclerViewPool (as you've done) and give it to all of your RecyclerView instances via setRecycledViewPool. This way, they'll share the same view pool.

You may prefer to increase its cache size to avoid churning Views when # of views between items differ a lot.

Btw, as a side suggestion, try to merge it into one RecyclerView instead of nested RecyclerViews. This way, animations etc can run much nicer. Also, scrolling at the same direction is problematic when you use RV inside RV and you can avoid that problem by merging them into one.

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