NestedScrollView 内的 Recyclerview 关闭底部表单

问题描述 投票:0回答:1

我有一个带有地图的页面,如果用户单击按钮,则会展开底页。在此底页中,有 2 个选项卡,其中有一个列表。如果我从下到上滚动列表,效果很好。相反的从上到下的移动,而不是向后滚动列表,它让我关闭底页。

我希望如果我向下滚动列表,如果列表不在顶部,则滚动列表,否则可以关闭底部表格。

我该如何解决这个问题?

我设计的页面是这样的:

  • 地图片段
<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"
tools:context=".ui.viability2.ViabilityFragment2">

    ...

     <fragment
     android:id="@+id/map"
     android:name="com.google.android.gms.maps.SupportMapFragment"
     class="com.google.android.gms.maps.SupportMapFragment"        
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:layout="@android:layout/simple_gallery_item" />

     ...

     <include layout="@layout/fragment_viability_bottom_sheet_v2" />

     ...

  • fragment_viability_bottom_sheet_v2
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.core.widget.NestedScrollView
    android:id="@+id/viabilityEventBottomSheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:background="@color/ftx_info_background"
    android:clickable="true"
    android:fillViewport="true"
    app:behavior_peekHeight="0dp"
    app:layout_behavior="@string/bottom_sheet_behavior">        
 
        <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

            ....

            <androidx.viewpager2.widget.ViewPager2
            android:id="@+id/viabilityViewPager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@id/buttonGroup" />

       </androidx.constraintlayout.widget.ConstraintLayout>


    </androidx.core.widget.NestedScrollView>
</merge>

然后在 MapFragment 类上,我在

ViewPager2
的适配器上加载 2 个片段(我们称它们为 X 和 Y)。这些片段非常简单,只是一个
RecyclerView
里面有一个
LinearLayout
和一些
AppCompatTextView

android android-recyclerview android-bottomsheetdialog
1个回答
0
投票

试试这个。

 recyclerView.setOnTouchListener { v, event ->
            v.parent.requestDisallowInterceptTouchEvent(true)
            v.onTouchEvent(event)
            true
        }
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.