就是一个activity包含一个自定义linearlayout再嵌套一个view,分别都有不同的响应事件
一开始所有dispatch和on都置为super
点击view
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: activity消费了他
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: view消费了他
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: view消费了他
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:27:02.530 5672-5672/com.example.eventdistribution I/xbh: activity消费了他
点击linear layout
12-17 05:29:27.910 8139-8139/com.example.eventdistribution I/xbh: activity消费了他
12-17 05:29:27.910 8139-8139/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:29:27.910 8139-8139/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:29:27.910 8139-8139/com.example.eventdistribution I/xbh: activity消费了他
activity的dispatch置为true,false效果一样
点击view
12-17 05:28:04.846 6531-6531/com.example.eventdistribution I/xbh: activity消费了他
点击linear layout
12-17 05:29:59.745 8691-8691/com.example.eventdistribution I/xbh: activity消费了他
activity的on置为true,false效果一样
点击view
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: activity消费了他
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: view消费了他
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: view消费了他
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:32:17.786 9807-9807/com.example.eventdistribution I/xbh: activity消费了他
点击linear layout
12-17 05:32:38.727 9807-9807/com.example.eventdistribution I/xbh: activity消费了他
12-17 05:32:38.727 9807-9807/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:32:38.727 9807-9807/com.example.eventdistribution I/xbh: linear layout消费了他
12-17 05:32:38.727 9807-9807/com.example.eventdistribution I/xbh: activity消费了他
这个是上篇文章图里没有的
此外button和textview用来做view的话,会大不一样。你在自定义他们的类中哪怕返回了super,接下来的DOWN事件也不会继续传播了。效果等同于返回true。此外你如果返回false,也不会继续向下传递。意思就是到了button的时候,不管在on中返回了什么,事件就到此为止了。
这是一个补充
其他都和上文的图中内容一样。