diff options
2 files changed, 21 insertions, 2 deletions
diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java index 238ab0f..a3dd16f 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java @@ -961,7 +961,11 @@ public class AHBottomNavigation extends FrameLayout { this.behaviorTranslationEnabled = behaviorTranslationEnabled; if (getParent() instanceof CoordinatorLayout) { ViewGroup.LayoutParams params = getLayoutParams(); - bottomNavigationBehavior = new AHBottomNavigationBehavior<>(behaviorTranslationEnabled); + if (bottomNavigationBehavior == null) { + bottomNavigationBehavior = new AHBottomNavigationBehavior<>(behaviorTranslationEnabled); + } else { + bottomNavigationBehavior.setBehaviorTranslationEnabled(behaviorTranslationEnabled); + } ((CoordinatorLayout.LayoutParams) params).setBehavior(bottomNavigationBehavior); if (needHideBottomNavigation) { needHideBottomNavigation = false; diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java index 43d6d39..5e5b900 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java @@ -94,8 +94,15 @@ public class AHBottomNavigationBehavior<V extends View> extends VerticalScrollin handleDirection(child, scrollDirection); } - + /** + * Handle scroll direction + * @param child + * @param scrollDirection + */ private void handleDirection(V child, int scrollDirection) { + if (!behaviorTranslationEnabled) { + return; + } if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && hidden) { hidden = false; animateOffset(child, 0, false, true); @@ -220,6 +227,14 @@ public class AHBottomNavigationBehavior<V extends View> extends VerticalScrollin } /** + * Enable or not the behavior translation + * @param behaviorTranslationEnabled + */ + public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) { + this.behaviorTranslationEnabled = behaviorTranslationEnabled; + } + + /** * Hide AHBottomNavigation with animation * @param view * @param offset |