【手机回收源码帝国】【精准峰谷线源码】【书籍封面psd源码】android touch 源码

2024-12-23 03:03:06 来源:狙击龙头股主图源码 分类:休闲

1.android onTouchEvent和setOnTouchListener中onTouch的区别
2.Android onTouchEvent和setOnTouchListener中onTouch的区别

android touch 源码

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监听最外层布局的滚动时,他们的就一样了。

本文地址:http://50.net.cn/html/33f686193105.html 欢迎转发