Onnestedscroll Called Only Once
I have a class public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior { public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { super()
Solution 1:
I solved the problem changing the visibility from GONE to INVISIBLE with the following code.
@OverridepublicvoidonNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child,
View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed);
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
child.hide(newFloatingActionButton.OnVisibilityChangedListener() {
@OverridepublicvoidonShown(FloatingActionButton fab) {
super.onShown(fab);
}
@OverridepublicvoidonHidden(FloatingActionButton fab) {
super.onHidden(fab);
fab.setVisibility(View.INVISIBLE);
}
});
} elseif (dyConsumed <= 0 && child.getVisibility() != View.VISIBLE) {
child.show();
}
}
Solution 2:
I have just answered to absolutely the same problem in another post, check it.
Speaking shortly, use the following:
compile'com.android.support:design:25.0.1'
Solution 3:
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
@Override
public void onHidden(FloatingActionButton fab) {
super.onHidden(fab);
fab.setVisibility(View.INVISIBLE);
}
});
} elseif (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
child.show();
}
}
Solution 4:
Do not set the visibility of FAB to GONE in child.hide() - use INVISIBLE instead. From 25.1.0, the scroll events are not passed on to views whose visibility is GONE
Solution 5:
For me i replace child.hide() with ((View)child).setVisibility(View.INVISIBLE).
Post a Comment for "Onnestedscroll Called Only Once"