AndroidにおけるonIntercept TouchEventとonTouchEventの呼び出しタイミング
3445 ワード
viewGroup , API , , , , !
:http://www.blogjava.net/TiGERTiAN/archive/2011/02/22/344869.html
onInterceptTouchEvent() ViewGroup , ViewGroup childView onTouchEvent() ,Android , ViewGroup childView, touch , view , LinearLayout ,TextView 。
onInterceptTouchEvent() , ViewGroup , touch 。 , touch ,touch onInterceptTouchEvent() onTouchEvent childView onInterceptTouchEvent() onTouchEvent() 。 , down move up 。
, , return true, , return false, , 。
SDK :
·You will receive the down event here.
·The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
·For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
·If you return true from here, you will not receive any following events: the target view will receive the same event but with the action ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
onInterceptTouchEvent() , , , :
1. down onInterceptTouchEvent()
2. ViewGroup onInterceptTouchEvent() down return false, move, up ViewGroup, down view onTouchEvent() 。
3. ViewGroup onInterceptTouchEvent() down return true, move, up onInterceptTouchEvent(), down ViewGroup onTouchEvent() , , view 。
4. view onTouchEvent() false, view onTouchEvent() 。
5. view onTouchEvent() true, view onTouchEvent() 。