Monday 24 April 2023

ModalBottomSheet. Dragging by the specific view

I want Dragging to turn on only by dragHandle element. in all other cases, it should be turned off.

xml:

<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainBottomSheetLayout"
android:background="@color/colorWhite">

<LinearLayout
    android:id="@+id/ModalBottomSheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    android:orientation="vertical">

    <com.google.android.material.bottomsheet.BottomSheetDragHandleView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/dragHandle"/>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="12dp"
        android:id="@+id/myRecView" />

</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

initialization behavior:

val behavior: BottomSheetBehavior<*> = (dialog as BottomSheetDialog).behavior
    behavior.state = BottomSheetBehavior.STATE_EXPANDED
    behavior.skipCollapsed = true
   

any ideas? I'm trying to do this with onTouchListener on dragHandle, but without any success.



from ModalBottomSheet. Dragging by the specific view

No comments:

Post a Comment