# NavigationBarView

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/navigation/NavigationBarView.java)

*** ** * ** ***


```
public abstract class NavigationBarView
```

<br />

Known direct subclasses [BottomNavigationView](https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView), [NavigationRailView](https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView)

|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView` | Represents a standard bottom navigation bar for application. |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView` | Represents a standard navigation rail view for application. |

*** ** * ** ***

Provides an abstract implementation of a navigation bar that can be used to implementation such as [Bottom Navigation](https://material.io/components/bottom-navigation) or [Navigation rail](https://material.io/components/navigation-rail).

Navigation bars make it easy for users to explore and switch between top-level views in a single tap.

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 navigation bar items. Menu items can also be used for programmatically selecting which destination is currently active. It can be done using `MenuItem#setChecked(true)`

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemReselectedListener` Listener for handling reselection events on navigation items. |
| `public interface https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemSelectedListener` Listener for handling selection events on navigation items. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ACTIVE_INDICATOR_WIDTH_MATCH_PARENT() = -1` The active indicator width fills up the width of its parent. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ACTIVE_INDICATOR_WIDTH_WRAP_CONTENT() = -2` The active indicator width wraps the content. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_GRAVITY_CENTER()` Item is placed at the center of its container |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_GRAVITY_START_CENTER()` Item is placed at the start center of its container |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_GRAVITY_TOP_CENTER()` Item is placed at the top center of its container |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START() = 1` Icon is placed at the top of the item |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_TOP() = 0` Icon is placed at the top of the item |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_AUTO() = -1` Label behaves as "labeled" when there are 3 items or less, or "selected" when there are 4 items or more. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_LABELED() = 1` Label is shown on all navigation items. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_SELECTED() = 0` Label is shown on the selected navigation item. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_UNLABELED() = 2` Label is not shown on any navigation items. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#NavigationBarView(Context,AttributeSet,int,int)( Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes )` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getActiveIndicatorLabelPadding()()` Get the distance between the active indicator container and the item's label. |
| `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getBadge(int)(int menuItemId)` Returns an instance of `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId`, null if none was initialized. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getHorizontalItemTextAppearanceActive()()` Returns the text appearance used for the active menu item label when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`). |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getHorizontalItemTextAppearanceInactive()()` Returns the text appearance used for inactive menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`). |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getIconLabelHorizontalSpacing()()` Get the horizontal distance between the icon and the item's label when the item is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorColor()()` Get the color of the active indicator drawable. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorExpandedHeight()()` Get the height of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorExpandedMarginHorizontal()()` Get the margin that will be maintained at the start and end of the expanded active indicator away from the edges of its parent container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorExpandedWidth()()` Get the width of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorHeight()()` Get the width of an item's active indicator. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorMarginHorizontal()()` Get the margin that will be maintained at the start and end of the active indicator away from the edges of its parent container. |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorShapeAppearance()()` Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemActiveIndicatorWidth()()` Get the width of an item's active indicator. |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemBackground()()` Returns the background drawable of the menu items. |
| `int` | `[getItemBackgroundResource](https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemBackgroundResource())()` **This method is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemBackground()` instead. <br /> |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemGravity()()` Returns the navigation items' layout gravity. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemIconGravity()()` Returns the current item icon gravity. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemIconSize()()` Returns the size provided for the menu item icons in pixels. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemIconTintList()()` Returns the tint which is applied to our menu items' icons. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemPaddingBottom()()` Get the distance from the bottom of an item's label to the bottom of the navigation bar item. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemPaddingTop()()` Get the distance from the top of an item's icon/active indicator to the top of the navigation bar item. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemRippleColor()()` Returns the color used to create a ripple as the background drawable of the menu items. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemTextAppearanceActive()()` Returns the text appearance used for the active menu item label. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemTextAppearanceInactive()()` Returns the text appearance used for inactive menu item labels. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemTextColor()()` Returns colors used for the different states (normal, selected, focused, etc.) of the menu item text. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getLabelMaxLines(int)(int labelMaxLines)` Returns the max lines limit for the label text. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getLabelVisibilityMode()()` Returns the current label visibility mode used by this `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView`. |
| `abstract int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getMaxItemCount()()` Returns the maximum number of items that can be shown in NavigationBarView. |
| `Menu` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getMenu()()` Returns the Menu instance associated with this navigation bar. |
| `ViewGroup` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getMenuViewGroup()()` Returns the android.view.ViewGroup associated with the navigation bar menu. |
| `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getOrCreateBadge(int)(int menuItemId)` Creates an instance of `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId` if none exists. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getScaleLabelTextWithFont()()` Returns whether or not the label text should scale with the system font size. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getSelectedItemId()()` Returns the currently selected menu item ID, or zero if there is no menu. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#inflateMenu(int)(int resId)` Inflate a menu resource into this navigation view. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#isItemActiveIndicatorEnabled()()` Get whether or not a selected item should show an active indicator. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#removeBadge(int)(int menuItemId)` Removes the `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setActiveIndicatorLabelPadding(int)(int activeIndicatorLabelPadding)` Set the distance between the active indicator container and the item's label. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setElevation(float)(float elevation)` Sets the base elevation of this view, in pixels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setHorizontalItemTextAppearanceActive(int)(int textAppearanceRes)` Sets the text appearance to be used for the menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`). |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setHorizontalItemTextAppearanceInactive(int)(int textAppearanceRes)` Sets the text appearance to be used for inactive menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`). |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setIconLabelHorizontalSpacing(int)(int iconLabelSpacing)` Set the horizontal distance between the icon and the item's label when the item is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorColor(ColorStateList)(ColorStateList csl)` Set the ColorStateList of the active indicator drawable. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorEnabled(boolean)(boolean enabled)` Set whether a selected item should show an active indicator. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorExpandedHeight(int)(int height)` Set the height of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorExpandedMarginHorizontal(int)(int horizontalMargin)` Set the horizontal margin that will be maintained at the start and end of the expanded active indicator, making sure the indicator maintains the given distance from the edge of its parent container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorExpandedPadding(int,int,int,int)( int paddingLeft, int paddingTop, int paddingRight, int paddingBottom )` Set the padding of the expanded active indicator wrapping the content. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorExpandedWidth(int)(int width)` Set the width of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorHeight(int)(int height)` Set the height of an item's active indicator. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorMarginHorizontal(int)(int horizontalMargin)` Set the horizontal margin that will be maintained at the start and end of the active indicator, making sure the indicator remains the given distance from the edge of its parent container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorShapeAppearance(com.google.android.material.shape.ShapeAppearanceModel)( https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel shapeAppearance )` Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemActiveIndicatorWidth(int)(int width)` Set the width of an item's active indicator. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackground(Drawable)(Drawable background)` Set the background of our menu items to the given drawable. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackgroundResource(int)(int resId)` Set the background of our menu items to the given resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemGravity(int)(int itemGravity)` Sets the navigation items' layout gravity. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconGravity(int)(int itemIconGravity)` Sets the navigation items' icon gravity. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconSize(int)(int iconSize)` Set the size to provide for the menu item icons. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconSizeRes(int)(int iconSizeRes)` Set the size to provide for the menu item icons using a resource ID. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconTintList(ColorStateList)(ColorStateList tint)` Set the tint which is applied to our menu items' icons. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemOnTouchListener(int,OnTouchListener)(int menuItemId, OnTouchListener onTouchListener)` Sets an android.view.View.OnTouchListener for the item view associated with the provided `menuItemId`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemPaddingBottom(int)(int paddingBottom)` Set the distance from the bottom of an item's label to the bottom of the navigation bar item. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemPaddingTop(int)(int paddingTop)` Set the distance from the top of an items icon/active indicator to the top of the navigation bar item. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemRippleColor(ColorStateList)(ColorStateList itemRippleColor)` Set the background of our menu items to be a ripple with the given colors. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemTextAppearanceActive(int)(int textAppearanceRes)` Sets the text appearance to be used for the menu item labels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemTextAppearanceActiveBoldEnabled(boolean)(boolean isBold)` Sets whether the active menu item labels are bold. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemTextAppearanceInactive(int)(int textAppearanceRes)` Sets the text appearance to be used for inactive menu item labels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemTextColor(ColorStateList)(ColorStateList textColor)` Set the colors to use for the different states (normal, selected, focused, etc.) of the menu item text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setLabelFontScalingEnabled(boolean)(boolean labelFontScalingEnabled)` Sets whether or not the label text should scale with the system font size. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setLabelMaxLines(int)(int labelMaxLines)` Set the max lines limit for the label text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setLabelVisibilityMode(int)(int labelVisibilityMode)` Sets the navigation items' label visibility mode. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setOnItemReselectedListener(com.google.android.material.navigation.NavigationBarView.OnItemReselectedListener)( https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemReselectedListener listener )` Set a listener that will be notified when the currently selected navigation item is reselected. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setOnItemSelectedListener(com.google.android.material.navigation.NavigationBarView.OnItemSelectedListener)( https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemSelectedListener listener )` Set a listener that will be notified when a navigation item is selected. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setSelectedItemId(int)(int itemId)` Set the selected menu item ID. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#isSubMenuSupported()()` Returns whether or not submenus are supported. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#onAttachedToWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#onRestoreInstanceState(Parcelable)(Parcelable state)` |
| `Parcelable` | `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#onSaveInstanceState()()` |

## Constants

### ACTIVE_INDICATOR_WIDTH_MATCH_PARENT

```
public static final int ACTIVE_INDICATOR_WIDTH_MATCH_PARENT = -1
```

The active indicator width fills up the width of its parent.

### ACTIVE_INDICATOR_WIDTH_WRAP_CONTENT

```
public static final int ACTIVE_INDICATOR_WIDTH_WRAP_CONTENT = -2
```

The active indicator width wraps the content.

### ITEM_GRAVITY_CENTER

```
public static final int ITEM_GRAVITY_CENTER
```

Item is placed at the center of its container

### ITEM_GRAVITY_START_CENTER

```
public static final int ITEM_GRAVITY_START_CENTER
```

Item is placed at the start center of its container

### ITEM_GRAVITY_TOP_CENTER

```
public static final int ITEM_GRAVITY_TOP_CENTER
```

Item is placed at the top center of its container

### ITEM_ICON_GRAVITY_START

```
public static final int ITEM_ICON_GRAVITY_START = 1
```

Icon is placed at the top of the item

### ITEM_ICON_GRAVITY_TOP

```
public static final int ITEM_ICON_GRAVITY_TOP = 0
```

Icon is placed at the top of the item

### LABEL_VISIBILITY_AUTO

```
public static final int LABEL_VISIBILITY_AUTO = -1
```

Label behaves as "labeled" when there are 3 items or less, or "selected" when there are 4 items or more.

### LABEL_VISIBILITY_LABELED

```
public static final int LABEL_VISIBILITY_LABELED = 1
```

Label is shown on all navigation items.

### LABEL_VISIBILITY_SELECTED

```
public static final int LABEL_VISIBILITY_SELECTED = 0
```

Label is shown on the selected navigation item.

### LABEL_VISIBILITY_UNLABELED

```
public static final int LABEL_VISIBILITY_UNLABELED = 2
```

Label is not shown on any navigation items.

## Public constructors

### NavigationBarView

```
public NavigationBarView(
    Context context,
    AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)
```

## Public methods

### getActiveIndicatorLabelPadding

```
public int getActiveIndicatorLabelPadding()
```

Get the distance between the active indicator container and the item's label.

### getBadge

```
public BadgeDrawable getBadge(int menuItemId)
```

Returns an instance of `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId`, null if none was initialized.

| Parameters |
|---|---|
| `int menuItemId` | Id of the menu item. |

| Returns |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` | an instance of BadgeDrawable associated with `menuItemId` or null. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getOrCreateBadge(int)` |   |

### getHorizontalItemTextAppearanceActive

```
public int getHorizontalItemTextAppearanceActive()
```

Returns the text appearance used for the active menu item label when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`).

| Returns |
|---|---|
| `int` | the text appearance ID used for the active menu item label |

### getHorizontalItemTextAppearanceInactive

```
public int getHorizontalItemTextAppearanceInactive()
```

Returns the text appearance used for inactive menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`).

| Returns |
|---|---|
| `int` | the text appearance ID used for inactive menu item labels |

### getIconLabelHorizontalSpacing

```
public int getIconLabelHorizontalSpacing()
```

Get the horizontal distance between the icon and the item's label when the item is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

### getItemActiveIndicatorColor

```
public ColorStateList getItemActiveIndicatorColor()
```

Get the color of the active indicator drawable.

| Returns |
|---|---|
| `ColorStateList` | A ColorStateList used as the color of the active indicator. |

### getItemActiveIndicatorExpandedHeight

```
public int getItemActiveIndicatorExpandedHeight()
```

Get the height of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

| Returns |
|---|---|
| `int` | The height, in pixels, of a menu item's expanded active indicator. |

### getItemActiveIndicatorExpandedMarginHorizontal

```
public int getItemActiveIndicatorExpandedMarginHorizontal()
```

Get the margin that will be maintained at the start and end of the expanded active indicator away from the edges of its parent container.

| Returns |
|---|---|
| `int` | The horizontal margin, in pixels. |

### getItemActiveIndicatorExpandedWidth

```
public int getItemActiveIndicatorExpandedWidth()
```

Get the width of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

| Returns |
|---|---|
| `int` | The width, in pixels, of a menu item's active indicator. |

### getItemActiveIndicatorHeight

```
public int getItemActiveIndicatorHeight()
```

Get the width of an item's active indicator.

| Returns |
|---|---|
| `int` | The width, in pixels, of a menu item's active indicator. |

### getItemActiveIndicatorMarginHorizontal

```
public int getItemActiveIndicatorMarginHorizontal()
```

Get the margin that will be maintained at the start and end of the active indicator away from the edges of its parent container.

| Returns |
|---|---|
| `int` | The horizontal margin, in pixels. |

### getItemActiveIndicatorShapeAppearance

```
public ShapeAppearanceModel getItemActiveIndicatorShapeAppearance()
```

Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable.

| Returns |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | The `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable. |

### getItemActiveIndicatorWidth

```
public int getItemActiveIndicatorWidth()
```

Get the width of an item's active indicator.

| Returns |
|---|---|
| `int` | The width, in pixels, of a menu item's active indicator. |

### getItemBackground

```
public Drawable getItemBackground()
```

Returns the background drawable of the menu items.

ref R.styleable#BottomNavigationView_itemBackground

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackground(Drawable)` |   |

### getItemBackgroundResource

```
public int [getItemBackgroundResource](https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemBackgroundResource())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemBackground()` instead.

Returns the background resource of the menu items.

ref R.styleable#BottomNavigationView_itemBackground

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackgroundResource(int)` |   |

### getItemGravity

```
public int getItemGravity()
```

Returns the navigation items' layout gravity.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemGravity(int)` |   |

### getItemIconGravity

```
public int getItemIconGravity()
```

Returns the current item icon gravity.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconGravity(int)` |   |

### getItemIconSize

```
public int getItemIconSize()
```

Returns the size provided for the menu item icons in pixels.

ref R.styleable#BottomNavigationView_itemIconSize

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconSize(int)` |   |

### getItemIconTintList

```
public ColorStateList getItemIconTintList()
```

Returns the tint which is applied to our menu items' icons.

ref R.styleable#BottomNavigationView_itemIconTint

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemIconTintList(ColorStateList)` |   |

### getItemPaddingBottom

```
public int getItemPaddingBottom()
```

Get the distance from the bottom of an item's label to the bottom of the navigation bar item.

### getItemPaddingTop

```
public int getItemPaddingTop()
```

Get the distance from the top of an item's icon/active indicator to the top of the navigation bar item.

### getItemRippleColor

```
public ColorStateList getItemRippleColor()
```

Returns the color used to create a ripple as the background drawable of the menu items. If a background is set using `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackground(Drawable)`, this will return null.

ref R.styleable#BottomNavigationView_itemRippleColor

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackground(Drawable)` |   |

### getItemTextAppearanceActive

```
public int getItemTextAppearanceActive()
```

Returns the text appearance used for the active menu item label.

| Returns |
|---|---|
| `int` | the text appearance ID used for the active menu item label |

### getItemTextAppearanceInactive

```
public int getItemTextAppearanceInactive()
```

Returns the text appearance used for inactive menu item labels.

| Returns |
|---|---|
| `int` | the text appearance ID used for inactive menu item labels |

### getItemTextColor

```
public ColorStateList getItemTextColor()
```

Returns colors used for the different states (normal, selected, focused, etc.) of the menu item text.

ref R.styleable#BottomNavigationView_itemTextColor

| Returns |
|---|---|
| `ColorStateList` | the ColorStateList of colors used for the different states of the menu items text. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemTextColor(ColorStateList)` |   |

### getLabelMaxLines

```
public int getLabelMaxLines(int labelMaxLines)
```

Returns the max lines limit for the label text.

### getLabelVisibilityMode

```
public int getLabelVisibilityMode()
```

Returns the current label visibility mode used by this `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView`.

ref com.google.android.material.R.styleable#BottomNavigationView_labelVisibilityMode

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setLabelVisibilityMode(int)` |   |

### getMaxItemCount

```
public abstract int getMaxItemCount()
```

Returns the maximum number of items that can be shown in NavigationBarView.

### getMenu

```
public Menu getMenu()
```

Returns the Menu instance associated with this navigation bar.

### getMenuViewGroup

```
public ViewGroup getMenuViewGroup()
```

Returns the android.view.ViewGroup associated with the navigation bar menu.

### getOrCreateBadge

```
public BadgeDrawable getOrCreateBadge(int menuItemId)
```

Creates an instance of `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId` if none exists. Initializes (if needed) and returns the associated instance of `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId`.

| Parameters |
|---|---|
| `int menuItemId` | Id of the menu item. |

| Returns |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` | an instance of BadgeDrawable associated with `menuItemId`. |

### getScaleLabelTextWithFont

```
public boolean getScaleLabelTextWithFont()
```

Returns whether or not the label text should scale with the system font size.

### getSelectedItemId

```
public int getSelectedItemId()
```

Returns the currently selected menu item ID, or zero if there is no menu.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setSelectedItemId(int)` |   |

### inflateMenu

```
public void inflateMenu(int resId)
```

Inflate a menu resource into this navigation view.

Existing items in the menu will not be modified or removed.

| Parameters |
|---|---|
| `int resId` | ID of a menu resource to inflate |

### isItemActiveIndicatorEnabled

```
public boolean isItemActiveIndicatorEnabled()
```

Get whether or not a selected item should show an active indicator.

| Returns |
|---|---|
| `boolean` | true if an active indicator will be shown when an item is selected. |

### removeBadge

```
public void removeBadge(int menuItemId)
```

Removes the `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` associated with `menuItemId`. Do nothing if none exists. Consider changing the visibility of the `https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable` if you only want to hide it temporarily.

| Parameters |
|---|---|
| `int menuItemId` | Id of the menu item. |

### setActiveIndicatorLabelPadding

```
public void setActiveIndicatorLabelPadding(int activeIndicatorLabelPadding)
```

Set the distance between the active indicator container and the item's label.

### setElevation

```
public void setElevation(float elevation)
```

Sets the base elevation of this view, in pixels.

ref R.styleable#BottomNavigationView_elevation

### setHorizontalItemTextAppearanceActive

```
public void setHorizontalItemTextAppearanceActive(int textAppearanceRes)
```

Sets the text appearance to be used for the menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`).

| Parameters |
|---|---|
| `int textAppearanceRes` | the text appearance ID used for menu item labels |

### setHorizontalItemTextAppearanceInactive

```
public void setHorizontalItemTextAppearanceInactive(int textAppearanceRes)
```

Sets the text appearance to be used for inactive menu item labels when they are in the horizontal item layout (when the start icon value is `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()`).

| Parameters |
|---|---|
| `int textAppearanceRes` | the text appearance ID used for inactive menu item labels |

### setIconLabelHorizontalSpacing

```
public void setIconLabelHorizontalSpacing(int iconLabelSpacing)
```

Set the horizontal distance between the icon and the item's label when the item is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

### setItemActiveIndicatorColor

```
public void setItemActiveIndicatorColor(ColorStateList csl)
```

Set the ColorStateList of the active indicator drawable.

| Parameters |
|---|---|
| `ColorStateList csl` | The ColorStateList used as the color of the active indicator. |

### setItemActiveIndicatorEnabled

```
public void setItemActiveIndicatorEnabled(boolean enabled)
```

Set whether a selected item should show an active indicator.

| Parameters |
|---|---|
| `boolean enabled` | true if a selected item should show an active indicator. |

### setItemActiveIndicatorExpandedHeight

```
public void setItemActiveIndicatorExpandedHeight(int height)
```

Set the height of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

| Parameters |
|---|---|
| `int height` | The height, in pixels, of the menu item's active indicator. |

### setItemActiveIndicatorExpandedMarginHorizontal

```
public void setItemActiveIndicatorExpandedMarginHorizontal(int horizontalMargin)
```

Set the horizontal margin that will be maintained at the start and end of the expanded active indicator, making sure the indicator maintains the given distance from the edge of its parent container.

| Parameters |
|---|---|
| `int horizontalMargin` | The horizontal margin, in pixels. |

### setItemActiveIndicatorExpandedPadding

```
public void setItemActiveIndicatorExpandedPadding(
    int paddingLeft,
    int paddingTop,
    int paddingRight,
    int paddingBottom
)
```

Set the padding of the expanded active indicator wrapping the content.

| Parameters |
|---|---|
| `int paddingLeft` | The left padding, in pixels. |
| `int paddingTop` | The top padding, in pixels. |
| `int paddingRight` | The right padding, in pixels. |
| `int paddingBottom` | The bottom padding, in pixels. |

### setItemActiveIndicatorExpandedWidth

```
public void setItemActiveIndicatorExpandedWidth(int width)
```

Set the width of an item's active indicator when it is expanded to wrap the item content, ie. when it is in the `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` configuration.

| Parameters |
|---|---|
| `int width` | The width, in pixels, of the menu item's expanded active indicator. The width may also be set as `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ACTIVE_INDICATOR_WIDTH_WRAP_CONTENT()` or `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ACTIVE_INDICATOR_WIDTH_MATCH_PARENT()`. |

### setItemActiveIndicatorHeight

```
public void setItemActiveIndicatorHeight(int height)
```

Set the height of an item's active indicator.

| Parameters |
|---|---|
| `int height` | The height, in pixels, of the menu item's active indicator. |

### setItemActiveIndicatorMarginHorizontal

```
public void setItemActiveIndicatorMarginHorizontal(int horizontalMargin)
```

Set the horizontal margin that will be maintained at the start and end of the active indicator, making sure the indicator remains the given distance from the edge of its parent container.

| Parameters |
|---|---|
| `int horizontalMargin` | The horizontal margin, in pixels. |

### setItemActiveIndicatorShapeAppearance

```
public void setItemActiveIndicatorShapeAppearance(
    ShapeAppearanceModel shapeAppearance
)
```

Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel shapeAppearance` | The `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` of the active indicator drawable. |

### setItemActiveIndicatorWidth

```
public void setItemActiveIndicatorWidth(int width)
```

Set the width of an item's active indicator.

| Parameters |
|---|---|
| `int width` | The width, in pixels, of the menu item's active indicator. |

### setItemBackground

```
public void setItemBackground(Drawable background)
```

Set the background of our menu items to the given drawable.

This will remove any ripple backgrounds created by `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemRippleColor(ColorStateList)`.

ref R.styleable#BottomNavigationView_itemBackground

| Parameters |
|---|---|
| `Drawable background` | The drawable for the background. |

### setItemBackgroundResource

```
public void setItemBackgroundResource(int resId)
```

Set the background of our menu items to the given resource.

This will remove any ripple backgrounds created by `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemRippleColor(ColorStateList)`.

ref R.styleable#BottomNavigationView_itemBackground

| Parameters |
|---|---|
| `int resId` | The identifier of the resource. |

### setItemGravity

```
public void setItemGravity(int itemGravity)
```

Sets the navigation items' layout gravity.

| Parameters |
|---|---|
| `int itemGravity` | the layout android.view.Gravity of the item |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemGravity()` |   |

### setItemIconGravity

```
public void setItemIconGravity(int itemIconGravity)
```

Sets the navigation items' icon gravity.

| Parameters |
|---|---|
| `int itemIconGravity` | the placement of the icon in the nav item one of `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_TOP()`, or `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#ITEM_ICON_GRAVITY_START()` |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemIconGravity()` |   |

### setItemIconSize

```
public void setItemIconSize(int iconSize)
```

Set the size to provide for the menu item icons.

For best image resolution, use an icon with the same size set in this method.

ref R.styleable#BottomNavigationView_itemIconSize

| Parameters |
|---|---|
| `int iconSize` | the size in pixels to provide for the menu item icons |

### setItemIconSizeRes

```
public void setItemIconSizeRes(int iconSizeRes)
```

Set the size to provide for the menu item icons using a resource ID.

For best image resolution, use an icon with the same size set in this method.

ref R.styleable#BottomNavigationView_itemIconSize

| Parameters |
|---|---|
| `int iconSizeRes` | the resource ID for the size to provide for the menu item icons |

### setItemIconTintList

```
public void setItemIconTintList(ColorStateList tint)
```

Set the tint which is applied to our menu items' icons.

ref R.styleable#BottomNavigationView_itemIconTint

| Parameters |
|---|---|
| `ColorStateList tint` | the tint to apply. |

### setItemOnTouchListener

```
public void setItemOnTouchListener(int menuItemId, OnTouchListener onTouchListener)
```

Sets an android.view.View.OnTouchListener for the item view associated with the provided `menuItemId`.

### setItemPaddingBottom

```
public void setItemPaddingBottom(int paddingBottom)
```

Set the distance from the bottom of an item's label to the bottom of the navigation bar item.

### setItemPaddingTop

```
public void setItemPaddingTop(int paddingTop)
```

Set the distance from the top of an items icon/active indicator to the top of the navigation bar item.

### setItemRippleColor

```
public void setItemRippleColor(ColorStateList itemRippleColor)
```

Set the background of our menu items to be a ripple with the given colors.

ref R.styleable#BottomNavigationView_itemRippleColor

| Parameters |
|---|---|
| `ColorStateList itemRippleColor` | The ColorStateList for the ripple. This will create a ripple background for menu items, replacing any background previously set by `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setItemBackground(Drawable)`. |

### setItemTextAppearanceActive

```
public void setItemTextAppearanceActive(int textAppearanceRes)
```

Sets the text appearance to be used for the menu item labels.

| Parameters |
|---|---|
| `int textAppearanceRes` | the text appearance ID used for menu item labels |

### setItemTextAppearanceActiveBoldEnabled

```
public void setItemTextAppearanceActiveBoldEnabled(boolean isBold)
```

Sets whether the active menu item labels are bold.

| Parameters |
|---|---|
| `boolean isBold` | whether the active menu item labels are bold |

### setItemTextAppearanceInactive

```
public void setItemTextAppearanceInactive(int textAppearanceRes)
```

Sets the text appearance to be used for inactive menu item labels.

| Parameters |
|---|---|
| `int textAppearanceRes` | the text appearance ID used for inactive menu item labels |

### setItemTextColor

```
public void setItemTextColor(ColorStateList textColor)
```

Set the colors to use for the different states (normal, selected, focused, etc.) of the menu item text.

ref R.styleable#BottomNavigationView_itemTextColor

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getItemTextColor()` |   |

### setLabelFontScalingEnabled

```
public void setLabelFontScalingEnabled(boolean labelFontScalingEnabled)
```

Sets whether or not the label text should scale with the system font size.

### setLabelMaxLines

```
public void setLabelMaxLines(int labelMaxLines)
```

Set the max lines limit for the label text.

### setLabelVisibilityMode

```
public void setLabelVisibilityMode(int labelVisibilityMode)
```

Sets the navigation items' label visibility mode.

The label is either always shown, never shown, or only shown when activated. Also supports "auto" mode, which uses the item count to determine whether to show or hide the label.

ref com.google.android.material.R.styleable#NavigationBarView_labelVisibilityMode

| Parameters |
|---|---|
| `int labelVisibilityMode` | mode which decides whether or not the label should be shown. Can be one of `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_AUTO()`, `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_SELECTED()`, `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_LABELED()`, or `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#LABEL_VISIBILITY_UNLABELED()` |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getLabelVisibilityMode()` |   |

### setOnItemReselectedListener

```
public void setOnItemReselectedListener(
    NavigationBarView.OnItemReselectedListener listener
)
```

Set a listener that will be notified when the currently selected navigation item is reselected. This does not require an `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemSelectedListener` to be set.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemReselectedListener listener` | The listener to notify |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setOnItemSelectedListener(com.google.android.material.navigation.NavigationBarView.OnItemSelectedListener)` |   |

### setOnItemSelectedListener

```
public void setOnItemSelectedListener(
    NavigationBarView.OnItemSelectedListener listener
)
```

Set a listener that will be notified when a navigation item is selected. This listener will also be notified when the currently selected item is reselected, unless an `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemReselectedListener` has also been set.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView.OnItemSelectedListener listener` | The listener to notify |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#setOnItemReselectedListener(com.google.android.material.navigation.NavigationBarView.OnItemReselectedListener)` |   |

### setSelectedItemId

```
public void setSelectedItemId(int itemId)
```

Set the selected menu item ID. This behaves the same as tapping on an item.

| Parameters |
|---|---|
| `int itemId` | The menu item ID. If no item has this ID, the current selection is unchanged. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView#getSelectedItemId()` |   |

## Protected methods

### isSubMenuSupported

```
protected boolean isSubMenuSupported()
```

Returns whether or not submenus are supported.

### onAttachedToWindow

```
protected void onAttachedToWindow()
```

### onRestoreInstanceState

```
protected void onRestoreInstanceState(Parcelable state)
```

### onSaveInstanceState

```
protected Parcelable onSaveInstanceState()
```