NestedScrolling解析

NestedScrolling機制(一)——概述](http://blog.csdn.net/al4fun/article/details/53888990)

NestedScrolling機制(二)——實例

NestedScrolling機制(三)——機制本質以及源碼解析

NestedScrolling機制(四)——最后一個例子

補充

看完以上文章后不知以下方法中的第一個參數和第二個參數的區別,遂調試看了下兩個對象,按照以上實例中的代碼發現第一個和第二個參數是一樣的對象(內存地址都一樣),遍查看了下源碼它們之間的區別。

public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes);

從NestedScrollingChildHelper這個幫助類的public boolean startNestedScroll(int axes)這個方法可以看到調用了
ViewParentCompat類中的方法

boolean onStartNestedScroll(ViewParent parent, View child, View target,int nestedScrollAxes);
這個方法中調用了

IMPL.onStartNestedScroll(parent, child, target, nestedScrollAxes);
而IMPL這個靜態變量的初始化是根據系統版本進行初始化的,往下看可以看到

return parent.onStartNestedScroll(child, target, nestedScrollAxes);
這段代碼中傳遞了child和target是在NestedScrollingChildHelper類的

public boolean startNestedScroll(int axes)中進行賦值的,賦值語句View child = mView;
mView即是初始化NestedScrollingChildHelper時傳遞的view,前面的例子中使用了self,所以是一樣的。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容