1.android onTouchEventåsetOnTouchListenerä¸onTouchçåºå«
2.Android onTouchEventåsetOnTouchListenerä¸onTouchçåºå«
android onTouchEventåsetOnTouchListenerä¸onTouchçåºå«
å¨dispatchè¿ç¨ä¸ä¼å å»checkå·²ç»è¢«setçOnTouchListenerï¼å¦æå¨OnTouchListenerçonTouché头return trueäºï¼å°±ä¼ç´æ¥return trueï¼ä¸åèµ°viewæ¬èº«çonTouchEventãå ·ä½ç代ç ï¼
/
*** Pass the touch screen motion event down to the target view,源码胜率 公式 源码 or this
* view if it is the target.
*
* @param event The motion event to be dispatched.
* @return True if the event was handled by the view, false otherwise.
*/
public boolean dispatchTouchEvent(MotionEvent event) {
if (mInputEventConsistencyVerifier != null) {
mInputEventConsistencyVerifier.onTouchEvent(event, 0);
}
if (onFilterTouchEventForSecurity(event)) {
//noinspection SimplifiableIfStatement
ListenerInfo li = mListenerInfo;
if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
&& li.mOnTouchListener.onTouch(this, event)) {
return true;
}
if (onTouchEvent(event)) {
return true;
}
}
if (mInputEventConsistencyVerifier != null) {
mInputEventConsistencyVerifier.onUnhandledEvent(event, 0);
}
return false;
}
Android onTouchEventåsetOnTouchListenerä¸onTouchçåºå«
onTouchEventæ¯ç¨æ¥çå¬æ´ä¸ªå±å¹çæ»å¨ï¼setOnTouchListeneræ¯çå¬æ个æ§ä»¶çãä½setOnTouchListenerçå¬æå¤å±å¸å±çæ»å¨æ¶ï¼ä»ä»¬çå°±ä¸æ ·äºã