美文网首页
学习NestedScrolling(一)

学习NestedScrolling(一)

作者: 火烛明 | 来源:发表于2017-04-20 13:22 被阅读0次

个人理解有限,有不对的地方希望大家指正。

NestedScrollingParent

一、包括的方法:

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

          public void  onNestedScrollAccepted(View child,View target, int nestedScrollAxes);

          public void  onStopNestedScroll(View target);

          public void  onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed);

          public void  onNestedPreScroll(View target, int dx, int dy, int[] consumed);

          public boolean  onNestedFling(View target, float velocityX, float velocityY, boolean consumed);

          public boolean  onNestedPreFling(View target, float velocityX, float velocityY);

          public int  getNestedScrollAxes();

1.对入参 View child的理解:它是实现NestedScrollingParent的父类ViewGroup中最外层实现NestedScrollingChild的子View

2.对fling的理解:就是当滑动控件,手指离开屏幕后,惯性的滑动

3.dx: 实现NestedScrollingParent的父类横向滑动的偏移量

4.dy: 实现NestedScrollingParent的父类纵向滑动的偏移量

5.int[] consumed 通知NestedScrollingChild消耗的多少偏移量

6.dxConsumed:target View横向消耗的偏移量

7.dyConsumed:target View纵向消耗的偏移量

8.dxUnconsumed:target View横向未消耗的偏移量

9.dyUnconsumed:target View纵向未消耗的偏移量

二、各方法调用的时机

1.当滑动屏幕的时候先调用 onStartNestedScroll();

2.如果onStartNestedScroll()返回true ,接着会调用 onNestedScrollAccepted();

3.滑动屏幕时,如果最父类布局拦截滑动事件,会调用onNestedPreScroll()

4.如果targetView开始滑动,会开始调用onNestedScroll();

相关文章

网友评论

      本文标题:学习NestedScrolling(一)

      本文链接:https://www.haomeiwen.com/subject/npyoettx.html