Search code examples
androidclickbottom-sheet

BottomSheetDialogFragment intercepting the touches of other views behind bottom sheet


I have added BottomSheetDialogFragment in my AppCompatActivity, I am always showing this bottom sheet on my activity because I want to use it as a bottom drawer view. So everything is working properly as I intended.

Now the problem is I do have another view on my activity ( obviously ), and those view does not receive the click event upon clicking them,

I have tried disabling the click on the touch_outside and coordinator view of the BottomSheetDialogFragment, but it still is blocking my click event on other views.

I have put below code inside my onViewCreated method and on debugging these view i do get those views but still and listeners are nullified but still it is intercepting my touch events

val touchOutsideView: View? = dialog?.window?.decorView?.findViewById(com.google.android.material.R.id.touch_outside)
val c: View? = dialog?.window?.decorView?.findViewById(com.google.android.material.R.id.coordinator)
c?.setOnClickListener(null)
c?.isClickable = false
touchOutsideView?.setOnClickListener(null)
touchOutsideView?.isClickable = false

Solution

  • Instead, I used a custom view and assigned app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" to the desired view and wrapped it using coordinator view