代码之家  ›  专栏  ›  技术社区  ›  Ljdawson

ScrollView中的RecyclerView

  •  0
  • Ljdawson  · 技术社区  · 10 年前

    我想将RecyclerView添加到ScrollView中,这样我就可以轻松地将标题添加到Recycler View中。

    我已调用setAutoMeasureEnabled(true)( part of the recently announced changes to the RecyclerView )到LayoutManager,但结果是不回收子视图。

    如果我的适配器中有10000个项目,将创建10000个视图。。。

    这是预期的行为吗?

    2 回复  |  直到 10 年前
        1
  •  0
  •   Ljdawson    10 年前

    我问了一个相关的Android问题,这不是应该如何使用:

    https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=74772

    对于任何读者,建议不要在带有setAutoMeasureEnabled(true)的ScrollView中使用RecyclerView。

        2
  •  -1
  •   Paulo Rodrigues    10 年前

    是的,将创建10.000个项目的10.000个视图,为了防止出现这种情况,需要一个分页解决方案和一个无止境的循环视图

    一些参考资料: https://gist.github.com/ssinss/e06f12ef66c51252563e

    https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView