事件的分发和消费机制
一、简介 :
Android 中与 Touch 事件相关的方法包括:dispatchTouchEvent(MotionEvent ev)、onInterceptTouchEvent(MotionEvent ev)、onTouchEvent(MotionEvent ev);能够响应这些方法的控件包括:ViewGroup、View、Activity。方法与控件的对应关系如下表所示:
Touch 事件相关方法 | 方法功能 |
ViewGroup |
View |
Activity |
public boolean dispatchTouchEvent(MotionEvent ev) | 事件分发 |
Yes | Yes | Yes |
public boolean onInterceptTouchEvent(MotionEvent ev) |
事件拦截 |
Yes | Yes / No | No |
public boolean onTouchEvent(MotionEvent ev) | 事件响应 |
Yes | Yes | Yes |
从这张表中我们可以看到 ViewGroup 和 View 对与 Touch 事件相关的三个方法均能响应,而 Activity 对 onInterceptTouchEvent(MotionEvent ev) 也就是事件拦截不进行响应。另外需要注意的是 View 对 onInterceptTouchEvent(MotionEvent ev) 的响应的前提是可以向该 View 中添加子 View,如果当前的 View 已经是一个最小的单元 View(比如 TextView),那么就无法向这个最小 View 中添加子 View,也就无法向子 View 进行事件的拦截,所以它没有 onInterceptTouchEvent(MotionEvent ev)。
dispatchTouchEvent() | 用来分派事件。 其中调用了onInterceptTouchEvent()和onTouchEvent(),一般不重写该方法 |
onInterceptTouchEvent() | 用来拦截事件。 ViewGroup类中的源码实现就是{return false;}表示不拦截该事件, 事件将向下传递(传递给其子View); 若手动重写该方法,使其返回true则表示拦截,事件将终止向下传递, 事件由当前ViewGroup类来处理,就是调用该类的onTouchEvent()方法 |
onTouchEvent() | 用来处理事件。 返回true则表示该View能处理该事件,事件将终止向上传递(传递给其父View); 返回false表示不能处理,则把事件传递给其父View的onTouchEvent()方法来处理 |
【以下动作均为点击自定义View】
一、无拦截,无消费:9个
03-31 18:36:41.620: I/MainActivity(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.686: I/MyViewGroup(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.699: I/MyViewGroup(13595): --->onInterceptTouchEvent: 0
03-31 18:36:41.699: I/MyView(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.730: I/MyView(13595): --->onTouchEvent: 0
03-31 18:36:41.730: I/MyViewGroup(13595): --->onTouchEvent: 0
03-31 18:36:41.730: I/MainActivity(13595): --->onTouchEvent: 0
03-31 18:36:41.811: I/MainActivity(13595): --->dispatchTouchEvent: 1
03-31 18:36:41.811: I/MainActivity(13595): --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 18:36:41.620: I/MainActivity(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.686: I/MyViewGroup(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.699: I/MyViewGroup(13595): --->onInterceptTouchEvent: 0
03-31 18:36:41.699: I/MyViewGroup(13595): -->onInterceptTouchEvent: false
03-31 18:36:41.699: I/MyView(13595): --->dispatchTouchEvent: 0
03-31 18:36:41.730: I/MyView(13595): --->onTouchEvent: 0
03-31 18:36:41.730: I/MyView(13595): -->onTouchEvent: false
03-31 18:36:41.730: I/MyView(13595): -->dispatchTouchEvent: false
03-31 18:36:41.730: I/MyViewGroup(13595): --->onTouchEvent: 0
03-31 18:36:41.730: I/MyViewGroup(13595): -->onTouchEvent: false
03-31 18:36:41.730: I/MyViewGroup(13595): -->dispatchTouchEvent: false
03-31 18:36:41.730: I/MainActivity(13595): --->onTouchEvent: 0
03-31 18:36:41.730: I/MainActivity(13595): -->onTouchEvent: false
03-31 18:36:41.751: I/MainActivity(13595): -->dispatchTouchEvent: false
03-31 18:36:41.811: I/MainActivity(13595): --->dispatchTouchEvent: 1
03-31 18:36:41.811: I/MainActivity(13595): --->onTouchEvent: 1
03-31 18:36:41.821: I/MainActivity(13595): -->onTouchEvent: false
03-31 18:36:41.821: I/MainActivity(13595): -->dispatchTouchEvent: false
二、ViewGroup拦截,无消费:7个
03-31 18:50:26.344: I/MainActivity(15304): --->dispatchTouchEvent: 0
03-31 18:50:26.344: I/MyViewGroup(15304): --->dispatchTouchEvent: 0
03-31 18:50:26.372: I/MyViewGroup(15304): --->onInterceptTouchEvent: 0
03-31 18:50:26.392: I/MyViewGroup(15304): --->onTouchEvent: 0
03-31 18:50:26.402: I/MainActivity(15304): --->onTouchEvent: 0
03-31 18:50:26.526: I/MainActivity(15304): --->dispatchTouchEvent: 1
03-31 18:50:26.526: I/MainActivity(15304): --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 18:50:26.344: I/MainActivity(15304): --->dispatchTouchEvent: 0
03-31 18:50:26.344: I/MyViewGroup(15304): --->dispatchTouchEvent: 0
03-31 18:50:26.372: I/MyViewGroup(15304): --->onInterceptTouchEvent: 0
03-31 18:50:26.392: I/MyViewGroup(15304): -->onInterceptTouchEvent: true
03-31 18:50:26.392: I/MyViewGroup(15304): --->onTouchEvent: 0
03-31 18:50:26.402: I/MyViewGroup(15304): -->onTouchEvent: false
03-31 18:50:26.402: I/MyViewGroup(15304): -->dispatchTouchEvent: false
03-31 18:50:26.402: I/MainActivity(15304): --->onTouchEvent: 0
03-31 18:50:26.402: I/MainActivity(15304): -->onTouchEvent: false
03-31 18:50:26.450: I/MainActivity(15304): -->dispatchTouchEvent: false
03-31 18:50:26.526: I/MainActivity(15304): --->dispatchTouchEvent: 1
03-31 18:50:26.526: I/MainActivity(15304): --->onTouchEvent: 1
03-31 18:50:26.526: I/MainActivity(15304): -->onTouchEvent: false
03-31 18:50:26.531: I/MainActivity(15304): -->dispatchTouchEvent: false
三、无拦截,View消费:10个
MainActivity: --->dispatchTouchEvent: 0
MyViewGroup: --->dispatchTouchEvent: 0
MyViewGroup: --->onInterceptTouchEvent: 0
MyView: --->dispatchTouchEvent: 0
MyView: --->onTouchEvent: 0
MainActivity: --->dispatchTouchEvent: 1
MyViewGroup: --->dispatchTouchEvent: 1
MyViewGroup: --->onInterceptTouchEvent: 1
MyView: --->dispatchTouchEvent: 1
MyView: --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 18:59:53.693: I/MainActivity(15743): --->dispatchTouchEvent: 0
03-31 18:59:53.693: I/MyViewGroup(15743): --->dispatchTouchEvent: 0
03-31 18:59:53.693: I/MyViewGroup(15743): --->onInterceptTouchEvent: 0
03-31 18:59:53.710: I/MyViewGroup(15743): -->onInterceptTouchEvent: false
03-31 18:59:53.784: I/MyView(15743): --->dispatchTouchEvent: 0
03-31 18:59:53.784: I/MyView(15743): --->onTouchEvent: 0
03-31 18:59:53.784: I/MyView(15743): -->onTouchEvent: true
03-31 18:59:53.792: I/MyView(15743): -->dispatchTouchEvent: true
03-31 18:59:53.792: I/MyViewGroup(15743): -->dispatchTouchEvent: true
03-31 18:59:53.792: I/MainActivity(15743): -->dispatchTouchEvent: true
03-31 18:59:53.801: I/MainActivity(15743): --->dispatchTouchEvent: 1
03-31 18:59:53.820: I/MyViewGroup(15743): --->dispatchTouchEvent: 1
03-31 18:59:53.820: I/MyViewGroup(15743): --->onInterceptTouchEvent: 1
03-31 18:59:53.820: I/MyViewGroup(15743): -->onInterceptTouchEvent: false
03-31 18:59:53.820: I/MyView(15743): --->dispatchTouchEvent: 1
03-31 18:59:53.820: I/MyView(15743): --->onTouchEvent: 1
03-31 18:59:53.820: I/MyView(15743): -->onTouchEvent: true
03-31 18:59:53.830: I/MyView(15743): -->dispatchTouchEvent: true
03-31 18:59:53.830: I/MyViewGroup(15743): -->dispatchTouchEvent: true
03-31 18:59:53.830: I/MainActivity(15743): -->dispatchTouchEvent: true
四、无拦截,仅有ViewGroup消费:9个
03-31 10:51:47.560: I/MainActivity(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.574: I/MyViewGroup(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.574: I/MyViewGroup(6728): --->onInterceptTouchEvent: 0
03-31 10:51:47.602: I/MyView(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.602: I/MyView(6728): --->onTouchEvent: 0
03-31 10:51:47.759: I/MyViewGroup(6728): --->onTouchEvent: 0
03-31 10:51:47.883: I/MainActivity(6728): --->dispatchTouchEvent: 1
03-31 10:51:47.919: I/MyViewGroup(6728): --->dispatchTouchEvent: 1
03-31 10:51:47.919: I/MyViewGroup(6728): --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 10:51:47.560: I/MainActivity(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.574: I/MyViewGroup(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.574: I/MyViewGroup(6728): --->onInterceptTouchEvent: 0
03-31 10:51:47.574: I/MyViewGroup(6728): -->onInterceptTouchEvent: false
03-31 10:51:47.602: I/MyView(6728): --->dispatchTouchEvent: 0
03-31 10:51:47.602: I/MyView(6728): --->onTouchEvent: 0
03-31 10:51:47.602: I/MyView(6728): -->onTouchEvent: false
03-31 10:51:47.759: I/MyView(6728): -->dispatchTouchEvent: false
03-31 10:51:47.759: I/MyViewGroup(6728): --->onTouchEvent: 0
03-31 10:51:47.759: I/MyViewGroup(6728): -->onTouchEvent: true
03-31 10:51:47.759: I/MyViewGroup(6728): -->dispatchTouchEvent: true
03-31 10:51:47.788: I/MainActivity(6728): -->dispatchTouchEvent: true
03-31 10:51:47.883: I/MainActivity(6728): --->dispatchTouchEvent: 1
03-31 10:51:47.919: I/MyViewGroup(6728): --->dispatchTouchEvent: 1
03-31 10:51:47.919: I/MyViewGroup(6728): --->onTouchEvent: 1
03-31 10:51:47.919: I/MyViewGroup(6728): -->onTouchEvent: true
03-31 10:51:47.919: I/MyViewGroup(6728): -->dispatchTouchEvent: true
03-31 10:51:47.919: I/MainActivity(6728): -->dispatchTouchEvent: true
五、无拦截,Activity消费:9个
03-31 19:43:53.682: I/MainActivity(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.696: I/MyViewGroup(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.702: I/MyViewGroup(19091): --->onInterceptTouchEvent: 0
03-31 19:43:53.722: I/MyView(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.722: I/MyView(19091): --->onTouchEvent: 0
03-31 19:43:53.773: I/MyViewGroup(19091): --->onTouchEvent: 0
03-31 19:43:53.794: I/MainActivity(19091): --->onTouchEvent: 0
03-31 19:43:53.848: I/MainActivity(19091): --->dispatchTouchEvent: 1
03-31 19:43:53.854: I/MainActivity(19091): --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 19:43:53.682: I/MainActivity(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.696: I/MyViewGroup(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.702: I/MyViewGroup(19091): --->onInterceptTouchEvent: 0
03-31 19:43:53.702: I/MyViewGroup(19091): -->onInterceptTouchEvent: false
03-31 19:43:53.722: I/MyView(19091): --->dispatchTouchEvent: 0
03-31 19:43:53.722: I/MyView(19091): --->onTouchEvent: 0
03-31 19:43:53.722: I/MyView(19091): -->onTouchEvent: false
03-31 19:43:53.773: I/MyView(19091): -->dispatchTouchEvent: false
03-31 19:43:53.773: I/MyViewGroup(19091): --->onTouchEvent: 0
03-31 19:43:53.794: I/MyViewGroup(19091): -->onTouchEvent: false
03-31 19:43:53.794: I/MyViewGroup(19091): -->dispatchTouchEvent: false
03-31 19:43:53.794: I/MainActivity(19091): --->onTouchEvent: 0
03-31 19:43:53.794: I/MainActivity(19091): -->onTouchEvent: true
03-31 19:43:53.794: I/MainActivity(19091): -->dispatchTouchEvent: true
03-31 19:43:53.848: I/MainActivity(19091): --->dispatchTouchEvent: 1
03-31 19:43:53.854: I/MainActivity(19091): --->onTouchEvent: 1
03-31 19:43:53.854: I/MainActivity(19091): -->onTouchEvent: true
03-31 19:43:53.854: I/MainActivity(19091): -->dispatchTouchEvent: true
六、无拦截、无消费,仅在ViewGroup上设置长按监听和单击监听,执行单击动作后:10个
03-31 20:00:59.553: I/MainActivity(23494): --->dispatchTouchEvent: 0
03-31 20:00:59.553: I/MyViewGroup(23494): --->dispatchTouchEvent: 0
03-31 20:00:59.553: I/MyViewGroup(23494): --->onInterceptTouchEvent: 0
03-31 20:00:59.562: I/MyView(23494): --->dispatchTouchEvent: 0
03-31 20:00:59.562: I/MyView(23494): --->onTouchEvent: 0
03-31 20:00:59.562: I/MyViewGroup(23494): --->onTouchEvent: 0
03-31 20:00:59.670: I/MainActivity(23494): --->dispatchTouchEvent: 1
03-31 20:00:59.670: I/MyViewGroup(23494): --->dispatchTouchEvent: 1
03-31 20:00:59.670: I/MyViewGroup(23494): --->onTouchEvent: 1
03-31 20:01:00.052: I/MyViewGroup(23494): --->OnClickListener
//以下是加上返回值的明细
03-31 10:37:54.239: I/MainActivity(30361): --->dispatchTouchEvent: 0
03-31 10:37:54.239: I/MyViewGroup(30361): --->dispatchTouchEvent: 0
03-31 10:37:54.239: I/MyViewGroup(30361): --->onInterceptTouchEvent: 0
03-31 10:37:54.239: I/MyViewGroup(30361): -->onInterceptTouchEvent: false
03-31 10:37:54.260: I/MyView(30361): --->dispatchTouchEvent: 0
03-31 10:37:54.260: I/MyView(30361): --->onTouchEvent: 0
03-31 10:37:54.260: I/MyView(30361): -->onTouchEvent: false
03-31 10:37:54.260: I/MyView(30361): -->dispatchTouchEvent: false
03-31 10:37:54.274: I/MyViewGroup(30361): --->onTouchEvent: 0
03-31 10:37:54.274: I/MyViewGroup(30361): -->onTouchEvent: true
03-31 10:37:54.274: I/MyViewGroup(30361): -->dispatchTouchEvent: true
03-31 10:37:54.274: I/MainActivity(30361): -->dispatchTouchEvent: true
03-31 10:37:54.431: I/MainActivity(30361): --->dispatchTouchEvent: 1
03-31 10:37:54.451: I/MyViewGroup(30361): --->dispatchTouchEvent: 1
03-31 10:37:54.461: I/MyViewGroup(30361): --->onTouchEvent: 1
03-31 10:37:54.461: I/MyViewGroup(30361): -->onTouchEvent: true
03-31 10:37:54.461: I/MyViewGroup(30361): -->dispatchTouchEvent: true
03-31 10:37:54.461: I/MainActivity(30361): -->dispatchTouchEvent: true
03-31 10:37:54.469: I/MyViewGroup(30361): --->OnClickListener
七、无拦截、无消费,仅在ViewGroup上设置长按监听和单击监听,执行长按动作后:(如果长按返回false:11个 , 如果长按返回true:10个)
03-31 10:40:35.029: I/MainActivity(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.029: I/MyViewGroup(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.029: I/MyViewGroup(30361): --->onInterceptTouchEvent: 0
03-31 10:40:35.040: I/MyView(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.040: I/MyView(30361): --->onTouchEvent: 0
03-31 10:40:35.040: I/MyViewGroup(30361): --->onTouchEvent: 0
03-31 10:40:35.552: I/MyViewGroup(30361): ---onLongClickListener执行了
03-31 10:40:36.174: I/MainActivity(30361): --->dispatchTouchEvent: 1
03-31 10:40:36.174: I/MyViewGroup(30361): --->dispatchTouchEvent: 1
03-31 10:40:36.214: I/MyViewGroup(30361): --->onTouchEvent: 1
03-31 10:40:36.229: I/MyViewGroup(30361): --->OnClickListener
//以下是加上返回值的明细
03-31 10:40:35.029: I/MainActivity(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.029: I/MyViewGroup(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.029: I/MyViewGroup(30361): --->onInterceptTouchEvent: 0
03-31 10:40:35.029: I/MyViewGroup(30361): -->onInterceptTouchEvent: false
03-31 10:40:35.040: I/MyView(30361): --->dispatchTouchEvent: 0
03-31 10:40:35.040: I/MyView(30361): --->onTouchEvent: 0
03-31 10:40:35.040: I/MyView(30361): -->onTouchEvent: false
03-31 10:40:35.040: I/MyView(30361): -->dispatchTouchEvent: false
03-31 10:40:35.040: I/MyViewGroup(30361): --->onTouchEvent: 0
03-31 10:40:35.040: I/MyViewGroup(30361): -->onTouchEvent: true
03-31 10:40:35.040: I/MyViewGroup(30361): -->dispatchTouchEvent: true
03-31 10:40:35.040: I/MainActivity(30361): -->dispatchTouchEvent: true
03-31 10:40:35.552: I/MyViewGroup(30361): ---onLongClickListener执行了
03-31 10:40:36.174: I/MainActivity(30361): --->dispatchTouchEvent: 1
03-31 10:40:36.174: I/MyViewGroup(30361): --->dispatchTouchEvent: 1
03-31 10:40:36.214: I/MyViewGroup(30361): --->onTouchEvent: 1
03-31 10:40:36.223: I/MyViewGroup(30361): -->onTouchEvent: true
03-31 10:40:36.223: I/MyViewGroup(30361): -->dispatchTouchEvent: true
03-31 10:40:36.223: I/MainActivity(30361): -->dispatchTouchEvent: true
03-31 10:40:36.229: I/MyViewGroup(30361): --->OnClickListener
八、无拦截、无消费,仅仅在View上设置长按监听和单击监听,执行单击动作后:11个
03-31 10:22:10.791: I/MainActivity(20714): --->dispatchTouchEvent: 0
03-31 10:22:10.791: I/MyViewGroup(20714): --->dispatchTouchEvent: 0
03-31 10:22:10.814: I/MyViewGroup(20714): --->onInterceptTouchEvent: 0
03-31 10:22:10.814: I/MyView(20714): --->dispatchTouchEvent: 0
03-31 10:22:10.820: I/MyView(20714): --->onTouchEvent: 0
03-31 10:22:10.994: I/MainActivity(20714): --->dispatchTouchEvent: 1
03-31 10:22:11.105: I/MyViewGroup(20714): --->dispatchTouchEvent: 1
03-31 10:22:11.105: I/MyViewGroup(20714): --->onInterceptTouchEvent: 1
03-31 10:22:11.150: I/MyView(20714): --->dispatchTouchEvent: 1
03-31 10:22:11.175: I/MyView(20714): --->onTouchEvent: 1
03-31 10:22:11.632: I/MyView(20714): --->OnClickListener
//以下是加上返回值的明细
03-31 10:32:17.759: I/MainActivity(20714): --->dispatchTouchEvent: 0
03-31 10:32:17.759: I/MyViewGroup(20714): --->dispatchTouchEvent: 0
03-31 10:32:17.770: I/MyViewGroup(20714): --->onInterceptTouchEvent: 0
03-31 10:32:17.770: I/MyViewGroup(20714): -->onInterceptTouchEvent: false
03-31 10:32:17.770: I/MyView(20714): --->dispatchTouchEvent: 0
03-31 10:32:17.770: I/MyView(20714): --->onTouchEvent: 0
03-31 10:32:17.770: I/MyView(20714): -->onTouchEvent: true
03-31 10:32:17.770: I/MyView(20714): -->dispatchTouchEvent: true
03-31 10:32:17.770: I/MyViewGroup(20714): -->dispatchTouchEvent: true
03-31 10:32:17.770: I/MainActivity(20714): -->dispatchTouchEvent: true
03-31 10:32:17.960: I/MainActivity(20714): --->dispatchTouchEvent: 1
03-31 10:32:17.974: I/MyViewGroup(20714): --->dispatchTouchEvent: 1
03-31 10:32:17.979: I/MyViewGroup(20714): --->onInterceptTouchEvent: 1
03-31 10:32:17.979: I/MyViewGroup(20714): -->onInterceptTouchEvent: false
03-31 10:32:17.979: I/MyView(20714): --->dispatchTouchEvent: 1
03-31 10:32:17.979: I/MyView(20714): --->onTouchEvent: 1
03-31 10:32:17.988: I/MyView(20714): -->onTouchEvent: true
03-31 10:32:17.988: I/MyView(20714): -->dispatchTouchEvent: true
03-31 10:32:18.003: I/MyViewGroup(20714): -->dispatchTouchEvent: true
03-31 10:32:18.003: I/MainActivity(20714): -->dispatchTouchEvent: true
03-31 10:32:18.010: I/MyView(20714): --->OnClickListener
九、无拦截、无消费,在View上设置长按监听和单击监听,执行长按动作后:(如果长按返回false:12个 , 如果长按返回true:11个)
03-31 10:28:50.179: I/MainActivity(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.210: I/MyViewGroup(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.210: I/MyViewGroup(20714): --->onInterceptTouchEvent: 0
03-31 10:28:50.260: I/MyView(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.260: I/MyView(20714): --->onTouchEvent: 0
03-31 10:28:50.777: I/MyView(20714): ---onLongClickListener执行了
03-31 10:28:51.699: I/MainActivity(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.699: I/MyViewGroup(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.716: I/MyViewGroup(20714): --->onInterceptTouchEvent: 1
03-31 10:28:51.716: I/MyView(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.724: I/MyView(20714): --->onTouchEvent: 1
03-31 10:28:51.740: I/MyView(20714): --->OnClickListener
//以下是加上返回值的明细
03-31 10:28:50.179: I/MainActivity(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.210: I/MyViewGroup(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.210: I/MyViewGroup(20714): --->onInterceptTouchEvent: 0
03-31 10:28:50.210: I/MyViewGroup(20714): -->onInterceptTouchEvent: false
03-31 10:28:50.260: I/MyView(20714): --->dispatchTouchEvent: 0
03-31 10:28:50.260: I/MyView(20714): --->onTouchEvent: 0
03-31 10:28:50.260: I/MyView(20714): -->onTouchEvent: true
03-31 10:28:50.349: I/MyView(20714): -->dispatchTouchEvent: true
03-31 10:28:50.349: I/MyViewGroup(20714): -->dispatchTouchEvent: true
03-31 10:28:50.349: I/MainActivity(20714): -->dispatchTouchEvent: true
03-31 10:28:50.777: I/MyView(20714): ---onLongClickListener执行了
03-31 10:28:51.699: I/MainActivity(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.699: I/MyViewGroup(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.716: I/MyViewGroup(20714): --->onInterceptTouchEvent: 1
03-31 10:28:51.716: I/MyViewGroup(20714): -->onInterceptTouchEvent: false
03-31 10:28:51.716: I/MyView(20714): --->dispatchTouchEvent: 1
03-31 10:28:51.724: I/MyView(20714): --->onTouchEvent: 1
03-31 10:28:51.724: I/MyView(20714): -->onTouchEvent: true
03-31 10:28:51.724: I/MyView(20714): -->dispatchTouchEvent: true
03-31 10:28:51.724: I/MyViewGroup(20714): -->dispatchTouchEvent: true
03-31 10:28:51.724: I/MainActivity(20714): -->dispatchTouchEvent: true
03-31 10:28:51.740: I/MyView(20714): --->OnClickListener
十、无拦截、无消费,仅在ViewGroup上设置clickable=true:个
03-31 10:47:26.390: I/MainActivity(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyViewGroup(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyViewGroup(4577): --->onInterceptTouchEvent: 0
03-31 10:47:26.390: I/MyView(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyView(4577): --->onTouchEvent: 0
03-31 10:47:26.399: I/MyViewGroup(4577): --->onTouchEvent: 0
03-31 10:47:26.541: I/MainActivity(4577): --->dispatchTouchEvent: 1
03-31 10:47:26.573: I/MyViewGroup(4577): --->dispatchTouchEvent: 1
03-31 10:47:26.573: I/MyViewGroup(4577): --->onTouchEvent: 1
//以下是加上返回值的明细
03-31 10:47:26.390: I/MainActivity(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyViewGroup(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyViewGroup(4577): --->onInterceptTouchEvent: 0
03-31 10:47:26.390: I/MyViewGroup(4577): -->onInterceptTouchEvent: false
03-31 10:47:26.390: I/MyView(4577): --->dispatchTouchEvent: 0
03-31 10:47:26.390: I/MyView(4577): --->onTouchEvent: 0
03-31 10:47:26.390: I/MyView(4577): -->onTouchEvent: false
03-31 10:47:26.399: I/MyView(4577): -->dispatchTouchEvent: false
03-31 10:47:26.399: I/MyViewGroup(4577): --->onTouchEvent: 0
03-31 10:47:26.399: I/MyViewGroup(4577): -->onTouchEvent: true
03-31 10:47:26.414: I/MyViewGroup(4577): -->dispatchTouchEvent: true
03-31 10:47:26.421: I/MainActivity(4577): -->dispatchTouchEvent: true
03-31 10:47:26.541: I/MainActivity(4577): --->dispatchTouchEvent: 1
03-31 10:47:26.573: I/MyViewGroup(4577): --->dispatchTouchEvent: 1
03-31 10:47:26.573: I/MyViewGroup(4577): --->onTouchEvent: 1
03-31 10:47:26.573: I/MyViewGroup(4577): -->onTouchEvent: true
03-31 10:47:26.573: I/MyViewGroup(4577): -->dispatchTouchEvent: true
03-31 10:47:26.573: I/MainActivity(4577): -->dispatchTouchEvent: true