您的位置:首页 > 移动开发 > Android开发

android--Touch Events 你应该记住的一些事

2013-11-22 21:55 429 查看
The 
onInterceptTouchEvent()
 method
is called whenever a touch event is detected on the surface of a 
ViewGroup
,
including on the surface of its children. If 
onInterceptTouchEvent()
 returns 
true
,
the 
MotionEvent 
is
intercepted, meaning it will be not be passed on to the child, but rather to the 
onTouchEvent()
 method
of the parent.

The 
onInterceptTouchEvent()
 method
gives a parent the chance to see any touch event before its children do. If you return 
true
 from 
onInterceptTouchEvent()
,
the child view that was previously handling touch events receives an
ACTION_CANCEL
,
and the events from that point forward are sent to the parent's 
onTouchEvent()
 method
for the usual handling. 
onInterceptTouchEvent()
 can
also return 
false
 and simply spy on events as they travel down the view hierarchy to their usual targets, which will handle the events with their own 
onTouchEvent()
.

详情见:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android event