Here is how to show & hide BottomNavigation when navigating to New Screen to do it.
You might have the bottom bar (BottomNavigation) that you intend to show in some screen of your app while hiding them in others.
NavController offers an OnDestinationChangedListener interface that is called when the NavController’s current destination or its arguments change. A new listener can be registered via the addOnDestinationChangedListener() method. Note that when calling addOnDestinationChangedListener(), if the current destination exists, it’s immediately sent to your listener.
NavigationUI uses OnDestinationChangedListener to make these common UI components navigation-aware. Note, however, that you can also use OnDestinationChangedListener on its own to make any custom UI or business logic aware of navigation events.
Using the NavHostController class’s OnDestinationChangedListener , you can selectively show or hide these UI screens depending on the target audience.
❌ Don’t use AnimatedVisibility to prevent screen jumping on hiding the bottom
bar (BottomNavigation).
Thank you so much for reading and I hope this article was helpful. If you have something to say to me, please leave a comment, and if this article was helpful, please share and clicks 👏 👏 👏 👏 👏.
Please visit the Profiler Github & Medium link below if you’d like to dive deep into more advanced techs.
Profiler :
Github : https://github.com/Lukoh/Profiler
Medium : https://medium.com/@lukohnam/profiler-a54f4f0f48f
Let me know or email me if you’re interested in my experience and techs. Please refer to my LinkedIn link below:
LinkedIn : https://www.linkedin.com/in/lukoh-nam-68207941/
Email : lukoh.nam@gmail.com