onNestedFling或onNestedPreFling行为回调在向上方向投掷时不会在CoordinatorLayout内触发NestedScrollView。但是,当我向下飞行时,他们会被触发。任何已知的问题?
当我用RecyclerView替换NestedScrollView时,会触发上述回调。
为了澄清,自定义行为类是:
public class DummyBehavior extends CoordinatorLayout.Behavior<View> {
public DummyBehavior() {
}
public DummyBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {
Log.i("onStartNestedScroll", "true");
return true;
}
@Override
public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY) {
Log.i("onNestedPreFling", "true");
return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
}
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY, boolean consumed) {
Log.i("onNestedFling", "true");
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
}
仅在RecyclerView中出现flings时,才会记录 Log.i("onNestedFling", "true");
和Log.i("onNestedPreFling", "true");
。
在NestedScrollView(不是向上翻转)的情况下,他们只会登录向下飞行。