https://kotlinlang.org logo
#android
Title
# android
w

Will Nixon

09/01/2020, 8:58 PM
Hi all, struggling with touch events at the moment. I’ve an activity constraint layout (the parent) that consists of 3 child constraint layouts (think header, body, footer). I want to be able to capture gestures inside the header, but at the moment it seems like I can only capture them on the parent itself (ie, if I “fling” up/down just in the margins outside of the body (which, itself, is a recycler view)). If I use
dispatchTouchEvent
in my activity, I can pass that even onto the gesture detector and every works fine. The problem is, then if I’m swiping in the recycler view, the function I only want associated with the header still gets called. Whats the best way to intercept touch events in the header? At the moment, the header is just a constraint layout, so all I can do is grab a reference to it via
R.id.header