Questions tagged [bottomnavigationview]

Questions related to bottom navigation bar. Bottom Navigation Bar menu item title,icon,populating content and and enabled states related issues. Bottom navigation bar item click listener, item background resource,item text color, inflate menu,max item count. Bottom Navigation Bar is an implementation of material design bottom navigation.

BottomNavigationView

BottomNavigationView Represents a standard bottom navigation bar for application. It is an implementation of material design bottom navigation.

Bottom navigation bars make it easy for users to explore and switch between top-level views in a single tap. It should be used when application has three to five top-level destinations.

The bar contents can be populated by specifying a menu resource file. Each menu item title, icon and enabled state will be used for displaying bottom navigation bar items. Menu items can also be used for programmatically selecting which destination is currently active.


                                         BottomNavigationView

This widget has a couple of attributes set on it. We can use these to set menu items we wish to display and the colours to be used throughout the Bottom Navigation View:

  • app:itemBackground — The background color to be used for the bottom navigation menu
  • app:itemIconTint — The tint to be used for the icons in the bottom navigation menu
  • app:itemTextColor — The color to be used for the text in the bottom navigation menu
  • app:menu — The menu resource to be used to display items in the bottom navigation menu

We can also set these values programmatically by using the following methods on our BottomNavigationView instance:

  • inflateMenu(int menuResource) — Inflate a menu for the bottom navigation view using a menu resource identifier.
  • setItemBackgroundResource(int backgroundResource) — The background to be used for the menu items.
  • setItemTextColor(ColorStateList colorStateList) — A ColorStateList used to color the text used for the menu items
  • setItemIconTintList(ColorStateList colorStateList) — A ColorStateList used to tint the icons used for the menu items

Useful Links:

1718 questions
9
votes
2 answers

Bottom Navigation View text style on selected item

How do I apply text style on selected item in BottomNavigationView? I can change colours but cannot figure out on how to change font styles (like font family or make it bold/italic) on selected menu item. Is there a way to do this only with XML? In…
Mintz
  • 929
  • 2
  • 11
  • 17
9
votes
2 answers

Bottom Navigation with center button arc or hump

Looking to modify the Bottom Navigation Bar with a main center action button which changes the shape of the navigation bar itself either an arc like so or a hump in the bottom nav enveloping the center button around it. I'm fine if I have to…
Kshitij Aggarwal
  • 5,287
  • 5
  • 34
  • 41
9
votes
4 answers

BottomSheetBehavior The view is not a child of CoordinatorLayout

I am trying to implement a persistent BottomSheet, my layout that is expected to be a BottomSheet is already a child of CoordinatorLayout but i don't know why i'm getting this Exception. this is my BottomSheet Layout :
Badr At
  • 658
  • 7
  • 22
9
votes
0 answers

Dark Theme with Bottom Navigation View

I am trying to make a day-night theme for my app. I am having troubles making the bottom navigation view switch from the white Background to black bg automatically. This is my bottom navigation…
Kevin Desai
  • 317
  • 3
  • 22
9
votes
1 answer

viewpager using bottom navigation view is not swiping the fragments

I want to swipe the tabs given at bottom. For that I have used ViewPager using BottomNavigationView by this. My code is given below.
9
votes
0 answers

Bottom Navigation loading Fragments is SLOW

I'm using a BottomNavigationView in my project and when I press an item and load e.g. My Ticket fragment, which generates a QR-code and takes a while, there is a huge delay until the item is selected. I tried to put an AsyncTask to load all data in…
9
votes
1 answer

Cross fade animation in react navigation tab navigator

I am using react navigation tab navigator and react native material bottom navigation and it currently swipes from screen to screen. How would I make it cross fade from one screen to another like the Material Design Guidelines suggests.…
9
votes
3 answers

Make BottomNavigationView stay under other view

I've implemented BottomNavigationView (BNV). My BNV always stay on top of other view, how can I make it stay under other view? This is my View
Harry T.
  • 3,478
  • 2
  • 21
  • 41
9
votes
4 answers

how to set top border for bottom navigation bar in android as shown in image

is it possible to set top border for bottom navigation bar in android, if possible tell me how we can do this, i am using the new bottom navigation view of android. Here is my code
sunil kushwah
  • 495
  • 1
  • 6
  • 20
9
votes
2 answers

Bottom Navigation View highlight selected item

I have added Bottom Navigation View to my activity XMl. I am unable to set the default checked item from the menu items. It always sets the first menu item as default. Also when I tap on other menu items the selected menu item is not hightlighted.…
user2622786
  • 779
  • 3
  • 9
  • 21
8
votes
2 answers

BottomNavigationBar without loading all pages at once

I have a screen with a BottomNavigationBar and an IndexedStack that swaps the child view based on the bottom bar index. Everything is ok, except that all four pages are created at once, loading their data that is quite heavy and slowing down the app…
Alessandro
  • 3,666
  • 2
  • 28
  • 41
8
votes
3 answers

Is there a way to add rounded corners to an android Material View bottom navigation?

I am trying to add rounded corners to my bottom navigation and i have tried changing widths and heights but its not working. I am using Relative layout with width set to 'fill_parent' and height set to 'warp_content' I have two icons login and…
8
votes
8 answers

kotlin.TypeCastException: null cannot be cast to non-null type androidx.navigation.fragment.NavHostFragment at NavigationExtensionsKt

I copied the NavigationExtensions.kt extension file from the NavigationAdvancedSample and I get this exception:
Amir
  • 284
  • 1
  • 3
  • 7
8
votes
1 answer

Save state of fragment A when navigating from bottomNavigationView to fragment B

I am new to Android and I have been struggling for some time now with saving state of a fragment. My app has 5 options in the bottomNavigationView (I am using the default activity from Android). In fragment A (actually called "SearchFragment") I…
8
votes
0 answers

Stop BottomNavigationView from Recreating Fragments

My bottom navigation view with Navigation Component is recreating my fragments each time I navigate. I would like a Singletop, how can I do this? I followed this tutorial:…
J_Strauton
  • 2,270
  • 3
  • 28
  • 70