В основном у меня есть фрагмент с определенным макетом, который имеет CoordinatorLayout в качестве родительского и статический фрагмент с BottomSheetBehaviour (также некоторые другие представления, не связанные с вопросом) `
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_activity_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
Some other views....
<fragment
android:id="@+id/home_apps_widget"
android:name="apps.calo.justLauncher.fragments.HomeAppsWidget"
android:layout_width="0dp"
android:layout_height="57dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<fragment
android:id="@+id/bottom_sheet_container"
android:name="apps.calo.justLauncher.fragments.AppDrawerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/app_drawer_fragament"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
tools:layout="@layout/app_drawer_fragament" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
`
Внутри статического фрагмента у меня следующий макет:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_drawer_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/app_drawer_background">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/app_drawer_indicator"
android:visibility="invisible"
android:layout_below="@id/app_search_widget"
android:layout_marginTop="8dp"
android:layout_marginBottom="5dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/app_list_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:itemCount="4"
android:clipToPadding="false"
app:spanCount="4"
tools:listitem="@layout/app_item"
android:layout_above="@id/app_drawer_indicator"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
android:orientation="vertical"
android:layout_below="@id/app_search_widget"
android:layout_marginTop="8dp"
android:layout_marginBottom="5dp" />
<apps.calo.justLauncher.view.Pager2Indicator
android:id="@+id/app_drawer_indicator"
android:layout_width="wrap_content"
android:layout_height="11dp"
android:layout_alignParentBottom="true"
app:piv_radius="3dp"
app:selectedColorCustom="page_indicator_selected"
app:tabIndicatorHeight="3dp"
app:unselectedColorCustom="page_indicator_unselected" />
</RelativeLayout>
</layout>
При следующей настройке у вас может быть только один активный (recyclerview или viewpager2), который можно изменить с помощью SharedPreferences.
Моя цель заключается в том, что когда вы прокручиваете RecyclerView вверх, ваш следующий свиток будет занят нижним листом (если вы снова попытаетесь прокрутить recyclerview вверх), и прикосновение переместит положение Y нижнего листа.
Я хочу то же самое с окном просмотра, но здесь вам не нужно прокручивать вверх, потому что он не прокручивается, поэтому в основном, если вы прокручиваете вниз, нижний лист возьмет на себя прикосновение.
При текущей настройке и RecyclerView, и ViewPager «проглатывают» прикосновение, и вы не можете управлять нижним листом с их помощью. Вы все еще можете свернуть нижний лист, если потянете его вниз, коснувшись представления, которое находится над recyclerview / viewpager.
У меня вопрос: как передать касание из recyclerview / viewpager в BottomSheet, чтобы управлять положением Y BottomSheet.
Интересно то, что когда я меняю ViewPager2 на ViewPager, я получаю желаемый эффект с RecyclerView, но не с ViewPager.
Спасибо!