android View事件传递
2016-01-26 18:51
609 查看
1:首先调用父类的LinearLayout/RelativeLayout 的dispatchTouchevent(MotionEvent event)进行事件的分发
(1):返回true:处理事件
(2):返回false,交给自己的onTouchEvent进行处理
(3):返回:return super.dispatchTouchEvent(ev);调用子View的dispathTouchevent(MotionEvent event);
如果子view为ViewGroup,继续遵循上述处理方式进行处理,如果子view为具体view,
2: 调用子view(具体的view,如button,TextView,ImageView等)的dispatchTouchevent(MotionEvent event)进行处理,
(1)返回ture,处理事件,不往下传递
(2)返回false,交给onTouchEvent(MotionEvent event)处理
(3)返回super.dispatchTouchevent(MotionEvent event)与返回false一样,
注意:如果在Action.Down的时候,onTouchEvent(MotionEvent event)返回false,则后续的Action.MOVE,和Action.UP不会继续到底此View
<=======================================================================================>
附件有测试demo
(1):返回true:处理事件
(2):返回false,交给自己的onTouchEvent进行处理
(3):返回:return super.dispatchTouchEvent(ev);调用子View的dispathTouchevent(MotionEvent event);
如果子view为ViewGroup,继续遵循上述处理方式进行处理,如果子view为具体view,
2: 调用子view(具体的view,如button,TextView,ImageView等)的dispatchTouchevent(MotionEvent event)进行处理,
(1)返回ture,处理事件,不往下传递
(2)返回false,交给onTouchEvent(MotionEvent event)处理
(3)返回super.dispatchTouchevent(MotionEvent event)与返回false一样,
注意:如果在Action.Down的时候,onTouchEvent(MotionEvent event)返回false,则后续的Action.MOVE,和Action.UP不会继续到底此View
<=======================================================================================>
附件有测试demo
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories