相关疑难解决方法(0)

BottomSheet + ViewPager2 拖动隐藏不起作用

我遇到了麻烦,我认为是我CoordinatorLayout的错,但不确定。我ViewPager2在 a 内部使用ConstraintLayout,我使用CoordinatorLayoutlike BottomSheet。但是当我拖动以隐藏它时效果不佳。我替换了ViewPager2byViewPager并且效果很好。我希望你能帮助我。

这是我的 XML 文件:

    <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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/bottom_sheet_behavior"
        app:behavior_hideable="false"
        app:behavior_peekHeight="60dp" >

        <androidx.viewpager2.widget.ViewPager2
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="4:3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:background="#0000FF"/>
    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android android-coordinatorlayout bottom-sheet android-viewpager2

13
推荐指数
1
解决办法
541
查看次数