bottomnavigationview

Fragment re-created on bottom navigation view item selected

对着背影说爱祢 提交于 2019-11-30 01:17:13
Following is my code for bottom navigation view item selected bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one fragment = FragmentA.newInstance(); break; case R.id.action_two: // Switch to page two fragment = FragmentB.newInstance(); break; case R.id.action_three: // Switch to page three fragment = FragmentC.newInstance(); break; }

How to dynamically hide a menu item in BottomNavigationView?

泄露秘密 提交于 2019-11-30 01:05:28
问题 I want to hide a menu item of BottomNavigationView dynamically based on some conditions. I tried the following but it is not working. mBottomNavigationView.getMenu() .findItem(R.id.item_name) .setVisible(false); mBottomNavigationView.invalidate(); 回答1: mBottomNavigationView.getMenu().removeItem(R.id.item_name); removeItem does the trick. Not sure why setVisible method is not working. 回答2: I tried most of solutions but this worked for me, For hiding an item dynamically : bottomNavigationView

Style BottomNavigationBar in Flutter

泄露秘密 提交于 2019-11-29 21:26:37
I am trying out Flutter and I am trying to change the colour of the BottomNavigationBar on the app but all I could achieve was change the colour of the BottomNavigationItem (icon and text). Here is where i declare my BottomNavigationBar : class _BottomNavigationState extends State<BottomNavigationHolder>{ @override Widget build(BuildContext context) { return new Scaffold( appBar: null, body: pages(), bottomNavigationBar:new BottomNavigationBar( items: <BottomNavigationBarItem>[ new BottomNavigationBarItem( icon: const Icon(Icons.home), title: new Text("Home") ), new BottomNavigationBarItem(

BottomNavigationView display both icons and text labels at all times

前提是你 提交于 2019-11-29 21:10:31
I am using android.support.design.widget.BottomNavigationView from design support library version 25 compile 'com.android.support:design:25.0.0' <android.support.design.widget.BottomNavigationView android:id="@+id/bottomBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_gravity="center" app:itemBackground="@color/colorPrimary" app:menu="@menu/bottom_navigation_main" android:forceHasOverlappingRendering="true"/> When there are only three actions in @menu/bottom_navigation_main, it displays both icons and text

Android Jetpack Navigation, BottomNavigationView with Youtube or Instagram like proper back navigation (fragment back stack)?

偶尔善良 提交于 2019-11-29 19:40:46
Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click? What I wanted, after choosing multiple tabs one after another by user and user click on back button app must redirect to the last page he/she opened. I achieved the same using Android ViewPager, by saving the currently selected item in an ArrayList. Is there any auto back stack after Android Jetpack Navigation Release? I want to achieve it using navigation graph activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas

How to implement new material BottomAppBar as BottomNavigationView

本小妞迷上赌 提交于 2019-11-29 12:33:36
问题 I was trying to implement the new BottomAppBar that usually looks like this: material BottomAppBar as a BottomNavigationView like in the Google home app that looks like this. My problem is that since I can fill the BottomAppBar only with a menu resource, I can't understand how to align my buttons to look like a BottomNavigationView (but with the "cut" for the Fab button) instead of align everything to one side of the BottomAppBar. How can I add a custom layout inside this new Material

BottomNavigationView - How to uncheck all MenuItems and keep Titles being displayed?

空扰寡人 提交于 2019-11-29 09:31:45
As I liked the design from BottomNavigationView I decided to implement a new Menu for my App with it, instead of just using simple buttons. I took this post as a guideline. According to BottomNavigationView 's documentation , its purpose is to provide quick navigation between top-level views of an app. It is primarily designed for use on mobile. In my case, I just want each MenuItem to launch an activity, but by default there is always one MenuItem selected: I tried to set the color to white with: app:itemIconTint="@color/white" app:itemTextColor="@color/white" Still, visibly selected MenuItem

How can I add a menu dynamically to bottom navigation view?

烂漫一生 提交于 2019-11-29 09:26:47
问题 Android has new ui element - BottomNavigationView I don't want to contain my menus in the xml files. I will receive the information about menu items and order from backend side. I want to create them dynamically and set into the BottomNavigationView in the onCreate() method. Can I do this? 回答1: By default, BottomNavigationView starts with an empty menu. You can use the getMenu() method to get the Menu instance, then add menu items as in the response above. For example, BottomNavigationView

How to increase icon size in android bottom navigation layout?

拟墨画扇 提交于 2019-11-29 05:57:49
I am using the bottom layout navigation style in android that was recently introduced by google in design library 25. In all the tutorials and questions i see, the images in their icons are a normal size, but mine are extra small, despite the fact that the image I'm saving to drawable folder is 72x72. Here is a screenshot: The icons should be at least 2, maybe even 3 times that size. How can I do it? Here is my code in my bottom_layout.xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"

How to highlight the item when pressed using BottomNavigationView between activities?

老子叫甜甜 提交于 2019-11-29 03:14:41
I have added Bottom Navigation View for my app but I need the Bottom Navigation View between activities instead of fragment so I have added this code to Java for all my 3 activities. When I select Second or Third in my phone all things are correct but the problem is the highlight goes to the First item. I need to highlight the item I press. I have used fragment and it works perfectly but I am still beginner for using fragment so I am using activities. The first activity code is: BottomNavigationView mBottomNavigation; mBottomNavigation =(BottomNavigationView) findViewById(R.id.BottomNavigator)