So I have 3 views, one big one on top of the other two. The one on top is transparent. I want to be able to register an onTouch
event on the views behind the big one on top, while the big one does nothing.
How can one do this?
you can you use addEventListener("click", function(){blah blah blah}, true) which would pass the event to its children. in the child element, you can handle the event as you wish.
Declare your TextView not clickable / focusable by using android:clickable="false" and android:focusable="false" or v. setClickable(false) and v. setFocusable(false) . The click events should be dispatched to the TextView 's parent now.
An event listener is an interface in the View class that contains a single callback method. These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI.
Take a look at using onInterceptTouchEvent(TouchEvent)
from ViewGroup
. The documentation there is pretty clear on how you can achieve what you are after here. You will likely want to extend
your transparent parent (unless it is already an extension that you wrote) and override this method to do your bidding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With