Home > Back-end >  BottomNavigationView: Disable animation for adding/inflating menu runtime
BottomNavigationView: Disable animation for adding/inflating menu runtime

Time:08-07

I have a problem with BottomNavigationView. I have to inflate menu runtime and I have a problem with default animation. It looks like tabs slide from right. Do you know how to disable this animation/behavior?

Default animation

XML:

    <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@ id/navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            app:itemActiveIndicatorStyle="@null"
            app:itemBackground="@null"
            app:itemIconSize="75dp"
            app:itemRippleColor="@null"
            app:labelVisibilityMode="unlabeled" />

Replacing menu runtime:

 binding.navigation.menu.clear()
 binding.navigation.inflateMenu(menuId)

CodePudding user response:

I solved problem by using TransitionManager.endTransitions(...)

binding.navigation.menu.clear()
binding.navigation.inflateMenu(menuId)
TransitionManager.endTransitions(binding.navigation.getChildAt(0) as NavigationBarMenuView)

Maybe it will help someone else. If you have better way to solve this let me know. Thanks in advance!

  • Related