What's the best way to implement navigation using single activity architecture and Jetpack navigation for an application with complex navigation that involves some different navigation strategies. For example:
Main application navigation using bottom navigation
In some of the bottom tabs fragments you can access some detail action that has its own navigation. For example, a detail view implemented:
as a full-screen fragment
without the bottom bar
with a top header with two tabs.
What's the best way to combine the main navigation with the two tabs from the detail view, or in general, more nested strategies. It's better to use several navigation files or can be implemented using only one?
Related
I have an activity contains a bottom navigation graph which has 5 tabs, I want to connect each tab to fragment using navigation graph, how can I linked it in navigation graph and manage the back stack.
Note: I don't want to use fragment transactions and manual code, I only want to use the navigation graph which is provided by jetpack navigator.
I am looking for example with Navigation Component in Android that will use multiple navigation graphs and then show how to nest them together?
Could you give any example or hint? It is new feature in Android, and there are only simple Single Activity examples with NavHostFragment, but how to use multiple navigation graphs correctly nest them or switch from one nav graph to another. What are the best practices?
Is it possible to combine both the navigation drawer and bottom navigation bar at same activity in android? I am able to use them on separate activities but am facing difficulties while combining them in a single activity.
I have an activity that extends fragmentActivity that has a navigation Drawer, and three different fragments.
Is there a way to make a navigation Drawer that has different buttons inside each of my fragments?
For example when you enter fragment 1 you will see certain buttons in the navigation Drawer, and when you go to fragment 2 you will see different buttons in the navigation Drawer.
You should just define which options are to be displayed in the NavigationDrawer depending on which current Fragment you're on, using a switch statement or if statement.
Check out this link:
How to change fragments using Android navigation drawer
Also, from this link https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html
As per the Android Design guide, any drawers positioned to the
left/start should always contain content for navigating around the
application, whereas any drawers positioned to the right/end should
always contain actions to take on the current content. This preserves
the same navigation left, actions right structure present in the
Action Bar and elsewhere.
So this type of thing seems like it was planned for when the NavigationDrawer was designed.
I was reading about Navigation Drawer and it was not until now that I came into this question: If my top views are going to be accessible through the Navigation Drawer, should I code each of them as Fragments or as Activities?
I want to know the way it was intended to be used, with Fragments or with Activities
The best way is to use Fragments.
When you click on an item, you should always replace the Fragment of your Main Activity without adding the elements in the Back Stack. This will create a seamless dynamic navigation instead of launching new activities and managing the drawer into them.
Here are some references
Google's design guidelines
Google's development guidelines