0

Im trying to make allow touches "behind" bottom sheet. But with any flags or modifiers it will dismiss anyway. The Bottom Sheet look like this

<androidx.constraintlayout.widget.ConstraintLayout 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="50dp"
    android:layout_gravity="bottom"
    android:background="@color/blue"
    android:paddingStart="16dp"
    android:paddingEnd="16dp"
    android:paddingBottom="15dp"
    app:behavior_hideable="true"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <TextView
        android:id="@+id/tvSaveFilter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="ok"
        android:textColor="@color/white"
        android:textSize="15sp"
        android:textStyle="normal"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/rSaveFilterButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="save?"
        android:textColor="@color/white"
        android:textSize="15sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

init bottom sheet

        val bottomSheetDialog =
            BottomSheetDialog(requireContext())
        val layout = saveBottomSheetBinding.inflate(LayoutInflater.from(requireContext()))
        bottomSheetDialog.setContentView(layout.root)
        bottomSheetDialog.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
        bottomSheetDialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)

        bottomSheetDialog.show()

I'm found only 1 solution for this problem, but its not working for me. Hope, someone already got this problem somedays

Spectator
  • 332
  • 1
  • 11

1 Answers1

0

You should create custom bottom sheet. Something like this.

class CustomBottomSheetDialog : BottomSheetDialog {

    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        super.onTouchEvent(ev)
        return false
    }

    override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
        return false
    }

}
c-an
  • 3,543
  • 5
  • 35
  • 82