1

I wanna use Scroll Behavior in my apps and the code looks like this,

@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();
}

I attached scroll behavior in fab (child)

app:layout_behavior="Adapter.ScrollAwareFABBehavior"

but the problem is when the child is hiding, dyUnconsume wont read user movement, dyUnconsume stop the counting. Is there any possibility for dyUnconsume do the counting even child is not showing and behavior still attached on fab ?

thanks in advance.

Nubi001
  • 23
  • 5
  • This question is anwered in [this other stackoverflow question](https://stackoverflow.com/questions/41807601/onnestedscroll-called-only-once/46727021#46727021). The hide method marks the FAB as `View.GONE`, therefore it is no longer considered part of the layout and gets no scroll events passed on. – carvaq Nov 20 '18 at 09:07
  • thank you very much carvaq, the solution you refered in the link, its work like a magic for me. – Nubi001 Nov 29 '18 at 04:53

0 Answers0