I know this got asked often, but all solutions(, I found,) don't work for me.
What I have is a CardView with an OnClickListener making a Toast (#toast1). Inside the CardView there are multiple views as also a WebView.
As mentioned elsewhere, to pass through the click through the WebView to the CardView I have done following:
- Set
android:clickable="false"
in WebView XML insert following under
CardView.setOnClickListener(...)
WebView.setOnTouchListener( (view, event) -> true);
I also replaced the lambda with an anonymous method, to see if its just this. No change.
What happens now is:
- At the border and over the other views, the clickListener is triggered and the toast appears
- Over the webView the clickListener isn't triggered.
- Also put a toast (#toast2) in touchLstener of WebView before returning
true
, and it gets triggered.
What I expect:
- Click will passed through WebView
- With #toast2 added: First show #toast2 then #toast1
What is a bit confusing, that in documentation of OnTouchListener, the return is following:
True if the listener has consumed the event, false otherwise.
For me that means:
true
: Don't pass click to below views, as listener consumed itfalse
: Pass click to below views, as listener didn't consumed it
But setting to false didn't change anything.