如何在BottomSheetDialogFragment内的ViewPager2上启用拖动?

BottomSheetDialogFragment在片段布局和打开STATE_EXPANDED模式上有一个很好的垂直拖动状态。它recyclerview里面有一个,垂直拖动可以在底部工作表上工作,但recyclerview由于滚动事件而无法工作。recyclerview当到达列表顶部并且仍然向上滚动以折叠底部工作表时,底部工作表拖动事件如何工作而不是滚动事件?

BottomSheetDialogFragment 层次结构:

FragmentRootLinearLayout -> ...BottomLinearLayout... -> ViewPager2 -> RecyclerView

BottomSheetDialogFragment xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/BookInfoFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/tool_sheet_bg"
    android:orientation="vertical"
    app:layout_behavior="@string/bottom_sheet_behavior"
    app:behavior_hideable="true"
    android:clickable="true"
    android:focusable="true">

    <LinearLayout
        android:id="@+id/tabs_linear_layout"
       
        android:layout_width="match_parent"
        android:layout_height="550dp"
        android:layout_marginTop="15dp"
        android:background="@drawable/xml_rounded_corner_bg2"
        android:clickable="true"
        android:focusable="true"
        android:paddingTop="0dp"
        android:paddingBottom="0dp">

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/book_loading_tablayout"
            android:layout_width="match_parent"
            android:layout_height="50dp" />

        <androidx.viewpager2.widget.ViewPager2
            android:id="@+id/book_loading_viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true"
            android:focusable="true" />

    </LinearLayout>

</LinearLayout>

编辑:问题出在 ViewPager2 上,当我将其更改为 ViewPager 时,拖动效果很好。同样的问题:BottomSheet + ViewPager2 拖动隐藏不起作用

以上是如何在BottomSheetDialogFragment内的ViewPager2上启用拖动?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>