I would like to create a linear layout which would behave similarly to ImageButton.
In my case, no one of the other solutions works!
I finally had to use OnTouchListener
as explained here, capturing the event when the user clicks in the parent view, and removing all childs OnClickListener
.
So the idea is, delegate the click behavior to the parent, and notify the child that is really clicked, if you want to propagate the event. ¡¡That's what we are looking for!!
Then, we need to check which child has been clicked. You can find a reference here to know how it´s done. But the idea is basiclly getting the area of the child, and asking for who contains the clicked coordinates, to perform his action (or not).