android ViewParent requestDisallowInterceptTouchEvent 测试
来源:互联网 发布:网络看电视软件哪个好 编辑:程序博客网 时间:2024/05/13 20:17
简单测试了一下 requestDisallowInterceptTouchEvent的使用:
两个类:
public static class myView extends View {@Overridepublic boolean onTouchEvent(MotionEvent event) {// TODO Auto-generated method stubint action = MotionEventCompat.ACTION_MASK & event.getAction();Log.e("FYF", "myView " + SystemUtils.motionEventToString(event));if (action == MotionEvent.ACTION_DOWN) {getParent().requestDisallowInterceptTouchEvent(true);}return true;}}
public static class myLinearLayout extends LinearLayout {@Overridepublic boolean onInterceptTouchEvent(MotionEvent ev) {// TODO Auto-generated method stub//return super.onInterceptTouchEvent(ev);int action = MotionEventCompat.ACTION_MASK & ev.getAction();if (action == MotionEvent.ACTION_DOWN) {return false;} else {return true;}}@Overridepublic boolean onTouchEvent(MotionEvent event) {// TODO Auto-generated method stubLog.e("FYF", "myLinearLayout " + SystemUtils.motionEventToString(event));return true;}}
在MyLinearLayout里放一个myView,
MyLineaLayout在interceptTouchEvevnt时,如果action 是 ACTION_DOWN, 那么就return false,将event继续传递给myView,
否则就自己直接截获,
myView没有requestDisallowInterceptTouchEvent(true):
E/FYF (11126): myView ACTION_DOWN
E/FYF (11126): myView ACTION_CANCEL
E/FYF (11126): myLinearLayout ACTION_MOVE
E/FYF (11126): myLinearLayout ACTION_MOVE
......................................
E/FYF (11126): myLinearLayout ACTION_UP
myView 运行了requestDisallowInterceptTouchEvent(true):
E/FYF (12069): myView ACTION_DOWN
E/FYF (12069): myView ACTION_MOVE
E/FYF (12069): myView ACTION_MOVE
......................................
E/FYF (12069): myView ACTION_UP
0 0
- android ViewParent requestDisallowInterceptTouchEvent 测试
- 【Android】requestDisallowInterceptTouchEvent
- Android requestDisallowInterceptTouchEvent
- android requestDisallowInterceptTouchEvent的用途
- Android TouchEvent之requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- requestDisallowInterceptTouchEvent
- android requestDisallowInterceptTouchEvent()使用时机问题?
- android 事件处理机制之requestDisallowInterceptTouchEvent
- android 事件处理机制之requestDisallowInterceptTouchEvent
- Android——编译体系中的 Copy
- Giving a presenation - 基础英语
- Unix下设计动态库的方法《精通Unix下C语言编程与项目实践》(一)
- 【JSP开发】response输出中文和数据的问题
- Android 异步消息处理机制 让你深入理解 Looper、Handler、Message三者关系
- android ViewParent requestDisallowInterceptTouchEvent 测试
- 怎样使网页页面变黑白
- 网站源码
- 一个新手接触手游项目碰到的bug及解决过程汇总
- 虚函数与虚继承寻踪
- opencv学习系列(六)--- 光流跟踪
- arcgis软件集合
- 执行make menuconfig 有许多错误
- linux quota命令参数及用法详解---linux磁盘配额限制设置和查看命令