-
Activity
1.boolean dispatchTouchEvent(MotionEvent event):分發(fā)事件
2.boolean onTouchEvent(MotionEvent event):處理事件的回調(diào)方法,返回true則消費(fèi)此事件 -
View
- boolean dispatchTouchEvent(MotionEvent evetn):分發(fā)事件
- boolean onTouchEvent(MotionEvent event):處理事件的回調(diào)方法
- void setOnTouchListener(OnThchListener l):設(shè)置事件監(jiān)聽器
- void setOnClickListener
- void setOnLongClickListener
- void setOnCreateContextMenuListener
-
ViewGroup
- boolean dispatchTouchEvent(MotionEvent evetn):分發(fā)事件
- boolean onInterceptTouchEvent(MotionEvent evetn):攔截事件
事件
- 分發(fā)-->dispatchTouchEvent()
- ViewGoup的攔截-->onInterceptTouchEvent返回true則攔截 傳給自己onTouchEvent判斷是否要消費(fèi),不消費(fèi)則往上傳遞
- 處理-->onTouchEvent() onTouch()
- 消費(fèi)-->處理事件的方法返回true 當(dāng)前事件對(duì)象就結(jié)束了
得到View的坐標(biāo),左上角坐標(biāo)(getLeft(),getTop()),右下角(getRight(),getBottom())
對(duì)View進(jìn)行動(dòng)態(tài)定位(layout(left,top,right,bottom))