【发布时间】:2017-01-05 15:36:34
【问题描述】:
我最近从支持库 recyclerview-v7:23.1.1 更新为 recyclerview-v7:25.1.0。
我的布局包含 2 个 recylerview,在屏幕上拆分为 50%。 xml代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scrollbars="none"/>
<android.support.v4.widget.Space
android:layout_width="@dimen/two_dp"
android:layout_height="match_parent"
android:background="@color/dark_gray"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scrollbars="none"/>
</LinearLayout>
现在对所有列表项调用 onBindViewHolder,而不仅仅是可见项。 这在更新以支持库 25.1.0 后开始发生。
如果去除权重,它工作正常,但需要并排有 2 个 recyclerviews。
如何让 recyclerview 回收视图而不是全部加载?
更新:它在 Marshmallow 及以上设备上运行良好。该问题存在于 Lollipop 或以下版本中。 你可以在这里找到一个演示项目: https://bitbucket.org/aniketit/recyclerviewtest
【问题讨论】:
-
贴上相关的onBindViewHolder代码
-
@BradleyWilson onBindViewHolder 的调用与其中的代码无关。我尝试了一个空的 onBindViewHolder 函数。
-
好吧,这很奇怪。我对你的 RecyclerViews 的 xml 没什么帮助,你能发布任何你认为相关或可能导致问题的代码(项目行布局等)
-
@BradleyWilson 我已经用一个演示项目更新了这个问题。
-
我在所有版本中都面临这个问题,在nestedscrollview中。?
标签: android android-recyclerview android-support-library