In the Android docs it says that the OnInterceptTouchEvent method of ViewGroup:
allows you to watch events as they are dispatched to your children
This somewhat implies to me, that it would only watch events from its children excluding its own events. Should that not be the case?
I did a quick test and the method fires regardless whether I tap on the child view (green square) or outside of it on the ViewGroup itself:
Custom view:
public class TestViewGroup extends FrameLayout {
/* Constructors
and other bla bla... */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.d("TestViewGroup", "TheTruth: " + ev.toString());
return true;
}
}
Layout:
<?xml version="1.0" encoding="utf-8"?>
<com.example.someapp.main.TestViewGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="bottom"
android:background="#151" />
</com.example.someapp.main.TestViewGroup>
Why?
Eventually I will display a map in the place of the green square, and I would like to listen to only those touch screen events which start from outside of the map's area.