1 year ago

#249179

test-img

user13756297

How to dispatch touch event from DialogFragment to Activity?

I have a DialogFragment, that shows on top of the MainActivity. When the user touches the dialog fragment I want to detect that motion event in the MainActivity below. Right now I am using this:

dialog?.window?.decorView?.setOnTouchListener {
        activity.dispatchTouchEvent()
}

But it doesn't work as I want to. It detects the touches on the white parts of the dialog, but not everywhere. For example I have an imageView in the dialog fragment's xml and if i touch that, the motion event is not detected at all. Is it possible to dispatch the events from every view in the dialog?

android

android-studio

android-activity

android-dialogfragment

0 Answers

Your Answer

Accepted video resources