NestedScrollingChild NestedScrollingParent API的粗略中文解释

NestedScrollingChild
NestedScrollingParent 这两个类,一起实现了进行混合滚动的事件的分发机制。

NestedScrollingChildHelper 这个类代理了很多常用的方法

NestedScrollingChild 接口下面的方法进行一一解释: 根据文旦进行翻译解释的

boolean dispatchNestedFling (float velocityX, 
            float velocityY, 
            boolean consumed) 
            这个方法通常表明各项条件已经符合要求,即将一个滑动事件,通常表明一个触摸滚动事件在一个方向上已经已一个速度
            结束了,或者沿着滚动方向速度超过了最小的速率。(表明如果一个滑动结束,或者是超过一定速度的滑动,会执行这个方法)
            分发子类的滚动的事件,如果子类不进行消费,就传到父类中。
            返回值:如果父类消费则返回true

boolean dispatchNestedPreFling (float velocityX, 
            float velocityY)

            在子类没有完全消费掉滑动快速滑动事件前,
            如果返回ture的话,那么父类直接消费掉这次的滑动事件,不会轮到子类。
            更好的使用方式:如果父类view消费并且这个方法返回false,那么自定义view有两种方式记录下来。
            1.如果自定义view是分页的并且需要处理固定的分页点,不要调用dispatchNestedPreFling ,消费这个滑动事件并且定位到有效位置
            2.如果父类不消耗filing事件,子视图不应该滚动,回到之前的位置。

boolean dispatchNestedPreScroll (int dx, 
            int dy, 
            int[] consumed, 
            int[] offsetInWindow)
            Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
            这是在子类没有进行任何消费之前进行分发,跟上面那个差不多,让父类进行拦截,看父类是否消耗,这个是滚动事件

boolean dispatchNestedScroll (int dxConsumed, 
            int dyConsumed, 
            int dxUnconsumed, 
            int dyUnconsumed, 
            int[] offsetInWindow)
            分发滚动事件,true代表可以分发,false不分发。

boolean hasNestedScrollingParent () 
            判断是否当前类有scrollingParent的父类

isNestedScrollingEnabled()
            当前的子类的嵌套是否可用
boolean startNestedScroll (int axes)
            沿一个方向上的滚动开始
void stopNestedScroll ()
            沿一个方向上的滚动结束

NestedScrollingParent

int getNestedScrollAxes ()
    获取滚动的方向

boolean onNestedFling (View target, 
            float velocityX, 
            float velocityY, 
            boolean consumed)  这里表明子类是否消耗了
    如果子类滚动已经到边界了,可以通过这个方法传到父类中,父类可以观察子类滚动,或者自己小号。
    如果父类消耗,或者应答,就要返回true

boolean onNestedPreFling (View target, 
            float velocityX, 
            float velocityY)
    在滚动消耗前做出反应。
    如果父类消费,那么返回true

void onNestedPreScroll (View target, 
            int dx, 
            int dy, 
            int[] consumed)
    在滚动前进行处理,consumed表示的是父类消耗了多少。


void onNestedScroll (View target, 
            int dxConsumed, 
            int dyConsumed, 
            int dxUnconsumed, 
            int dyUnconsumed)
    在相应的滚动方向做出处理。当子类分发滚动事件的时候,这个方法进行调用。

void onNestedScrollAccepted (View child, 
            View target, 
            int nestedScrollAxes)
    onStartNestedScroll当下面的这个方法返回true的时候,调用这个方法,表示就是成功的对滚动事件进行了响应。

boolean onStartNestedScroll (View child, 
            View target, 
            int nestedScrollAxes)
在拦截的继承关系中,每个父类都有机会去拦截处理事件,在原始的滚动事件对出检测,然后判断是否进行滚动
返回true表示viewParent接受它的滚动操作。接受是后续进行处理的前提

void onStopNestedScroll (View target)
    当滚动操作停止的时候进行的处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值