I have an overlay ViewGroup that is the size of the screen which I want to use to show an effect when the user interacts with the app, but still passes the onTouch event to any
I tried all of the solutions in the above answers however still had issues receiving all touch events while still allowing children views to consume the events. In my scenario I would like to listen in on events that a child views would consume. I could not receive follow up events after a overlapping child view started consuming events.
I finally found a solution that works. Using the RxBinding library you can observe all touch events including events that are consumed by overlapping children views.
Kotlin Code snippet
RxView.touches(view)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
object : Observer {
override fun onCompleted() {
}
override fun onNext(t: MotionEvent?) {
Log.d("motion event onNext $t")
}
override fun onError(e: Throwable?) {
}
}
)
See here and here for more details.