【vncviewer 源码】【维护中网页源码】【vc 多线程 源码】android touch 源码

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

更多内容请点击【热点】专栏

精彩资讯