I am using bottom navigation
for single activity
.
What I'm trying to do is do various screen transitions through the bottom menu
(fragment
).
And we are implementing a function to switch screens without moving the menu on the switched screen.
I've considered using the BottomNavigation Activity
provided by Android (probably the JetPack navigation component
).
However, I saw that there were many problems with this component. Especially the NavController
.
For example, when i switch screens and then come back, i have to manually restore the view state.
Because NavController
uses replace()
instead of show/hide
, so I've been told so
In addition to these problems, using FragmentManager
and show/hide
is more recommended, is it true?
So I'm currently using setOnNavigationItemSelectedListener
, but it's actually more difficult because I'm implementing the screen transition myself.
I would definitely use the provided NavController if I was you.
It has had its issues over the years, some of them which you are describing. Most of these problems were removed in version 2.4.0-alpha01. Version 2.4.0-alpha02 is also out now.
Check out this sample to see the BottomNavigationView in action, together with the new NavController. It is a great starting point for any app.