Consider this hypothetical hierarchy...
LinearLayoutA <-- I want to handle the touches here...
|
+-SomeViewX
+-SomeOtherViewY
+-LinearLayoutB
|
+-CustomView1 <-- for these three CustomView objects
+-CustomView2
+-CustomView3
What I would like to do is know which (grand)child view was touched and handle it from within LinearLayoutA. Also, I don't control those views so I can't simply make them handle the touch internally and delegate to their parent(s).
Currently I'm manually adding touch listeners to CustomViews 1-3 but that requires a lot of 'boilerplate' work and also means I won't get notified if someone clicks on SomeViewX or SomeOtherViewY, only the specific ones I've attached the listener to.
Now in other languages such as C# with WPF, if you handle the event at the equivalent of LinearLayoutA, part of the event payload is a source, which is the view that initiated the touch, but I'm not aware of any such thing in Android.
All the examples I've seen require looping through the children and hit-testing them, then disambiguating by z-order if there's an overlap, and when you've identified the one child, then you have to go through its children and repeat.
So, is there a built-in, or 'Androidy' way to know which child in a ViewGroup was touched without manually iterating and hit-testing, or manually attaching listeners to all its children?