只能有一个子视图,下面的代码中NestedScrollView里面有两个,那就弄成一个
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_home_looper"
android:layout_width="match_parent"
android:layout_height="180dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_home_pager_content_list"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vp_home_looper" />
</androidx.core.widget.NestedScrollView>
解决:使用一个ViewGroup包裹两个子视图,这里使用LinearLayout,其他也行
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_home_looper"
android:layout_width="match_parent"
android:layout_height="180dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_home_pager_content_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>