Я хотел объединить CollapsingToolbarLayout с ViewPager. В ViewPager я раздуваю 3 фрагмента. Один фрагмент с NestedScrollView ( прокрутка не работает должным образом ), два фрагмента с RecyclerViews, которые работают хорошо (у всех установлено app:layout_behavior="@string/appbar_scrolling_view_behavior"
).
Если я перетащу фрагмент с помощью NestedScrollView, ViewPager начнет прокручиваться вбок (этого не происходит в RecyclerView), см. Здесь: вложенная прокрутка gif
Я также пробовал простой ScrollView вместо NestedScrollView, но ScrollView вообще нельзя было прокручивать.
Есть предложения?
Мои файлы макета:
Макет действия (activity_media_view.f xml)
<?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:id="@+id/fragment_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.list.MediaViewActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_behavior=".activities.list.ui.main.CustomAppBarBehavior"
android:theme="@style/ToolBarStyle">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="?attr/toolbarColor"
app:titleEnabled="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<!-- Some RelativeLayout Content -->
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ToolBarStyle.Popup"
app:theme="@style/ToolBarStyle"
android:id="@+id/toolbar"
android:background="?attr/toolbarColor"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_gravity="bottom"
app:tabIndicatorFullWidth="false"
app:tabSelectedTextColor="?attr/colorOnBackground"
app:tabIndicatorColor="?android:colorAccent"
android:background="?attr/toolbarColor"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="@+id/include"
layout="@layout/content_media_view" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Включенный NestedScrollView с ViewPager (content_media_view.f xml)
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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:background="?android:colorBackground"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.list.MediaViewActivity"
tools:showIn="@layout/activity_media_view">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
Первый фрагмент в ViewPager
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:padding="5dp"
android:layout_height="wrap_content"
android:layout_marginBottom="85dp">
<!-- some table content-->
</TableLayout>
</androidx.core.widget.NestedScrollView>