Android NestedScrollView内部的RecyclerView一次激发所有onBindViewHolder
我想要一个带有RecyclerView的可滚动屏幕作为其子级,层次结构如下所示:Android NestedScrollView内部的RecyclerView一次激发所有onBindViewHolder,android,user-interface,android-recyclerview,android-nestedscrollview,Android,User Interface,Android Recyclerview,Android Nestedscrollview,我想要一个带有RecyclerView的可滚动屏幕作为其子级,层次结构如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout ... android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.s
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
.../>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
.../>
<FrameLayout
.../>
<android.support.v7.widget.RecyclerView
android:id="@+id/list_contacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"/>
<FrameLayout
.../>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
但它毕竟失败了
我知道其中一个解决方案是实现异构recyclerView,但我想避免它。有什么想法吗?可能是因为在这种情况下,recyclerview无法知道自身的高度。 你能试试吗
layoutManager.isAutoMeasureEnabled=true
如果不希望每个视图都绑定在前面,则不能使用
wrap\u content
height<代码>包裹内容高度使视图无法循环。使用非CrollRecyclerView
这使得在运行时分配recyclerview的高度变得简单。看看这个@BenP。好的,你写了如何不实现它。有没有建议如何实现将相当复杂的页眉(或/和页脚)放在列表中第一个(或最后一个)元素之前的对象列表?
layoutManager.isAutoMeasureEnabled=true