When I use NestedScrollView in CoordinatorLayout as below, I can't scroll smoothly in ViewPager2.Sometimes it works, But only when I scroll fast. Where am I wrong? Any help would be appreciated
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:background="@color/white">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:id="@+id/toolbar_layout"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
app:toolbarId="@+id/title_toolbar"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
app:contentScrim="?attr/colorPrimary">
<!-- somethin -->
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
android:id="@+id/view_pager"></androidx.viewpager2.widget.ViewPager2>
</androidx.core.widget.NestedScrollView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_gravity="bottom"
app:layout_behavior=".ui.NavBehavior"
android:id="@+id/main_nav_container">
</androidx.cardview.widget.CardView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>