I have a main activity with bottom nav and a frame layout to hold each fragment I have made for the numbers of icon in my botton nav. I have a fragment page in which i have a text and want to change the fragment and also the bottom nav icon from the click action on text.
Please refer to below links :
Android new Bottom Navigation bar or BottomNavigationView
How to Code a Bottom Navigation Bar for an Android App
Android Working with Bottom Navigation
Related
I used Coordinator layout and app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" on Bottom Navigation Bar.
This works fine for auto hiding Bottom Navigation bar but
I don't want to hide my Bottom navigation bar for all tabs, I want to hide it for selected tab like Home and Menu other tabs scrolling should not hide bottom navigation bar.
Is there any way to implement this with Coordinator layout?
The scroll flag used within the attribute app:layout_scrollFlags must be enabled for any scroll effects to take into effect. This flag must be enabled along with enterAlways, enterAlwaysCollapsed, exitUntilCollapsed, or snap
Coordinate Layout
I have a jetpack navigation graph setup with bottom navigation and an action bar. The bottom navigation has 3 tabs. 1 of these tabs has a detailed fragment that I would like to display the back-arrow on in the action bar.
In MainActivity onCreate(), I've added:
supportActionBar?.setDisplayHomeAsUpEnabled(true)
This displays the back button on every tab & fragment.
How can I prevent display of the back button unless the user is navigated to a non-top level fragment? Is there a method that detects when this particular navigation has occured? If so, I presume I can do something like supportActionBar?.setDisplayHomeAsUpEnabled(false)
Additionally, is there a way I can display a custom back arrow on the child pages? The default arrow does not fit the UI.
Happy to provide more detail if needed.
You could use a combination of setupWithNavController(BottomNavigationView,NavController) and setupActionBarWithNavController(AppCompatActivity,NavController,AppBarConfiguration) from NavigationUI. The first will bind the bottom navigation to the navigation controller, the second will set up the support action bar to regard the navigation.
With the AppBarConfiguration.getTopLevelDestinations() you will be able to configure when to display the back arrow. The default is to only regard the root of the navigation graph as a top level destination, but you can also use another builder to define a set of top level destinations.
I want to add title under the icon that as default appears when i create the navigation drawer .
like in red border
Its not possible if you use normal ActionBarToggle, you can provide your own custom layout in toolbar and add menu icon to it but back animation will not work. Also you will have to handle click events on the menu your self
I'm trying to add navigation bottom bar with 4 activities(each activity has each layout xml files) to swith with tab the bottom bar. I saw some examples and tutorials, they implement navigation bottom bar with fragment activites. I have already made all activites(including google map), when I tried to switch FragmentActivity to Fragment, it causes lots of errors.
SO, does navigation bottom bar only works with Fragment?
I am implementing Navigation Drawer in my Main Activity. When I load a fragment for the drawer item, the action bar gets overlapped above the fragment.I am required to give a top margin of about 48 dp, so that my views come below the action bar. How can I bring my fragment layout below the ActionBar?
layout_marginTop="?attr/actionBarSize"
use this in your layout it changes in size based on screen configuration automatically
Have a look at this tutorial:
android-sidebar-navigation-drawer-with-icons