NestedScrolling機制(一)——概述](http://blog.csdn.net/al4fun/article/details/53888990)
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,所以是一樣的。