我想在我的应用程序中使用滚动行为,并且代码看起来像这样,
@Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
final View directTargetChild, final View target, final int nestedScrollAxes) {
return true;
}
@Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout,
final FloatingActionButton child,
final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed,dxUnconsumed, dyUnconsumed);
if (dyUnconsumed > 0 && child.getVisibility() == View.VISIBLE) {
child.hide();
}if (dyUnconsumed < 0 && child.getVisibility() != View.VISIBLE) {
child.show();
}
我在fab(子级)中附加了滚动行为
app:layout_behavior="Adapter.ScrollAwareFABBehavior"
但是问题是当孩子隐藏时,dyUnconsume不会读取用户动作,dyUnconsume停止计数。 dyUnconsume是否有可能进行计数,即使孩子没有显示并且工厂上的行为仍然存在?
提前谢谢。