我已经浪费了至少一个星期的时间在这件事上,唯一有效的解决办法就是移除
nestedscrollview
,你
必须移除
这个
. 如果你碰巧有多个
view
recyclerview
,则必须将它们添加为
回收视图
通过设置不同的viewholder,然后添加
app:layout_behavior="@string/appbar_scrolling_view_behavior"
回收视图
就我而言,要求如下:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:fitsSystemWindows="true"
app:layout_constraintTop_toTopOf="parent">
<!-- Scrollable view here -->
<com.google.android.material.appbar.AppBarLayout
.... >
<com.google.android.material.appbar.CollapsingToolbarLayout
....>
<androidx.appcompat.widget.Toolbar
....>
<include
android:id="@+id/toolbar_header_view"
.... />
</androidx.appcompat.widget.Toolbar>
<include layout="@layout/widget_header" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
....>
<LinearLayout orientation="vertical" ....>
<View .../> <!-- I needed to have these two views along with recyclerview and i wanted them to do nestedscroll along with recyclerview -->
<View .../>
<androidx.recyclerview.widget.RecyclerView
.... />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
我以前需要有两种观点
回收视图
我想让他们一起做nestedscroll
. 唯一有效的方法是将它们删除到视图中,并将它们添加为视图的前两项
回收视图
,然后添加
app:layout_behavior="@string/appbar_scrolling_view_behavior"
到
swipetorefresh
希望这对别人有帮助。如果需要,我会添加更多信息。