我在一个LinearLayout
中垂直放置了两个RecyclerViews
。我需要让它们都可以滚动,这就是为什么我把LinearLayout
放在NestedScrollView
里面的原因
这是我的布局文件。
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/featured_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/all_topic_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
此外,我还禁用了Java代码中的嵌套滚动。
disableNestedScrolling(findViewById(R.id.all_topic_list));
disableNestedScrolling(findViewById(R.id.featured_list));
我的RecylerView
库版本是26.1.0
这可以很好地工作,但随后将为列表中的所有项调用onBindViewHolder
方法。理想情况下,应该只为列表中的可见项调用它。
我认为这个问题的发生是因为我将wrap_content
提供给了RecyclerView
。许多关于this问题的答案表明这个问题在v23.2.1中已经解决了,但我已经在使用v26.1.0了。如何解决这个问题?
https://stackoverflow.com/questions/50655664
复制相似问题