# NavigationRailView

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

*** ** * ** ***


```
public class NavigationRailView extends NavigationBarView
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [com.google.android.material.navigation.NavigationBarView](https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView) ||
|   | ↳ | [com.google.android.material.navigationrail.NavigationRailView](https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView) |

*** ** * ** ***

Represents a standard navigation rail view for application. It is an implementation of [Material Design navigation rail.](https://material.io/components/navigation-rail).

Navigation rails make it easy for users to explore and switch between top-level views in a single tap. They should be placed at the side edge of large screen devices such as tablets, when an application has three to seven 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 navigation rail bar items. Menu items can also be used for programmatically selecting which destination is currently active. It can be done using `MenuItem#setChecked(true)`.

A header view (such as a `https://developer.android.com/reference/com/google/android/material/floatingactionbutton/FloatingActionButton`, logo, etc.) can be added with the `app:headerLayout` attribute or by using addHeaderView.

```
layout resource file:
<com.google.android.material.navigationrail.NavigationRailView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schema.android.com/apk/res/res-auto"
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:menu="@menu/my_navigation_items"
    app:headerLayout="@layout/my_navigation_rail_fab" />

res/menu/my_navigation_items.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/action_search"
         android:title="@string/menu_search"
         android:icon="@drawable/ic_search" />
    <item android:id="@+id/action_settings"
         android:title="@string/menu_settings"
         android:icon="@drawable/ic_add" />
    <item android:id="@+id/action_navigation"
         android:title="@string/menu_navigation"
         android:icon="@drawable/ic_action_navigation_menu" />
</menu>

res/layout/my_navigation_rail_fab.xml:
<com.google.android.material.floatingactionbutton.FloatingActionButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/my_navigation_rail_fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="@string/my_navigation_rail_fab_content_desc"
    app:srcCompat="@drawable/ic_add" />
```

For more information, see the [component developer guidance](https://github.com/material-components/material-components-android/blob/master/docs/components/NavigationRail.md) and [design guidelines](https://material.io/components/navigation-rail/overview).

## Summary

| ### Public fields |
|---|---|
| `View` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#headerView()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#submenuDividersEnabled()` |

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

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(View)(View headerView)` Adds the specified View if any, to appear at the top of the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(int)(int layoutRes)` Adds the specified View layout resource, to appear at the top of the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#collapse()()` Collapse the navigation rail. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#expand()()` Expand the navigation rail. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getCollapsedItemMinimumHeight()()` Gets the minimum height of a navigation rail menu item when the navigation rail is collapsed. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getExpandedItemMinimumHeight()()` Gets the minimum height of a navigation rail menu item when the navigation rail is expanded. |
| `View` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getHeaderView()()` Returns reference to the header view if any, that is currently attached the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getItemGravity()()` Returns the navigation items' layout gravity. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getItemIconGravity()()` Returns the current item icon gravity. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getItemMinimumHeight()()` Get the current minimum height each item in the navigation rail's menu should be. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getItemSpacing()()` Get the current padding in between the navigation rail menu items. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getMaxItemCount()()` Returns the maximum number of items that can be shown in NavigationBarView. |
| `int` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getMenuGravity()()` Gets the current gravity setting for how destinations in the menu view will be grouped. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getSubmenuDividersEnabled()()` Get whether or not to enable the dividers which go between each subgroup in the menu. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#isExpanded()()` Returns whether or not the navigation rail is currently expanded. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#onTouchEvent(MotionEvent)(MotionEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#removeHeaderView()()` Removes the current header view if any, from the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setCollapsedItemMinimumHeight(int)(int minHeight)` Sets the minimum height of a navigation rail menu item when the navigation rail is collapsed. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setCollapsedItemSpacing(int)(int itemSpacing)` Sets the padding in between the navigation rail menu items when the navigation rail is collapsed. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setExpandedItemMinimumHeight(int)(int minHeight)` Sets the minimum height of a navigation rail menu item when the navigation rail is expanded. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setItemGravity(int)(int itemGravity)` Sets the navigation items' layout gravity. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setItemIconGravity(int)(int itemIconGravity)` Sets the navigation items' icon gravity. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setItemMinimumHeight(int)(int minHeight)` Set the minimum height each item in the navigation rail's menu should use. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setItemSpacing(int)(int itemSpacing)` Set the padding in between the navigation rail menu items. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setMenuGravity(int)(int gravity)` Sets how destinations in the menu view will be grouped. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#setSubmenuDividersEnabled(boolean)(boolean submenuDividersEnabled)` Set whether or not to enable the dividers which go between each subgroup in the menu. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#isSubMenuSupported()()` Returns whether or not submenus are supported. |
| `void` | `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#onMeasure(int,int)(int widthMeasureSpec, int heightMeasureSpec)` |

| ### Inherited Constants |
|---|
| From [com.google.android.material.navigation.NavigationBarView](https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView) |---|---| | `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. | |

| ### Inherited methods |
|---|
| From [com.google.android.material.navigation.NavigationBarView](https://developer.android.com/reference/com/google/android/material/navigation/NavigationBarView) |---|---| | `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#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`. | | `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#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()()` | | `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#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. | |

## Public fields

### headerView

```
public View headerView
```

### submenuDividersEnabled

```
public boolean submenuDividersEnabled
```

## Public constructors

### NavigationRailView

```
public NavigationRailView(Context context)
```

### NavigationRailView

```
public NavigationRailView(Context context, AttributeSet attrs)
```

### NavigationRailView

```
public NavigationRailView(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)
```

### NavigationRailView

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

## Public methods

### addHeaderView

```
public void addHeaderView(View headerView)
```

Adds the specified View if any, to appear at the top of the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. If the view already has a header view attached to it, it will be removed first.

| Parameters |
|---|---|
| `View headerView` | reference to the View that should be attached. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#removeHeaderView()` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getHeaderView()` |   |

### addHeaderView

```
public void addHeaderView(int layoutRes)
```

Adds the specified View layout resource, to appear at the top of the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`. If the view already has a header view attached to it, it will be removed first.

| Parameters |
|---|---|
| `int layoutRes` | the unique resource identifier to the layout that should be attached. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(View)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#removeHeaderView()` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getHeaderView()` |   |

### collapse

```
public void collapse()
```

Collapse the navigation rail.

### expand

```
public void expand()
```

Expand the navigation rail.

### getCollapsedItemMinimumHeight

```
public int getCollapsedItemMinimumHeight()
```

Gets the minimum height of a navigation rail menu item when the navigation rail is collapsed.

### getExpandedItemMinimumHeight

```
public int getExpandedItemMinimumHeight()
```

Gets the minimum height of a navigation rail menu item when the navigation rail is expanded.

### getHeaderView

```
public View getHeaderView()
```

Returns reference to the header view if any, that is currently attached the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(View)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#removeHeaderView()` |   |

### 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)` |   |

### getItemMinimumHeight

```
public int getItemMinimumHeight()
```

Get the current minimum height each item in the navigation rail's menu should be.

### getItemSpacing

```
public int getItemSpacing()
```

Get the current padding in between the navigation rail menu items.

### getMaxItemCount

```
public int getMaxItemCount()
```

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

### getMenuGravity

```
public int getMenuGravity()
```

Gets the current gravity setting for how destinations in the menu view will be grouped.

### getSubmenuDividersEnabled

```
public boolean getSubmenuDividersEnabled()
```

Get whether or not to enable the dividers which go between each subgroup in the menu.

### isExpanded

```
public boolean isExpanded()
```

Returns whether or not the navigation rail is currently expanded.

### onTouchEvent

```
public boolean onTouchEvent(MotionEvent event)
```

### removeHeaderView

```
public void removeHeaderView()
```

Removes the current header view if any, from the `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView`.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#addHeaderView(View)` |   |
| `https://developer.android.com/reference/com/google/android/material/navigationrail/NavigationRailView#getHeaderView()` |   |

### setCollapsedItemMinimumHeight

```
public void setCollapsedItemMinimumHeight(int minHeight)
```

Sets the minimum height of a navigation rail menu item when the navigation rail is collapsed.

| Parameters |
|---|---|
| `int minHeight` | the min height of the item when the nav rail is collapsed |

### setCollapsedItemSpacing

```
public void setCollapsedItemSpacing(int itemSpacing)
```

Sets the padding in between the navigation rail menu items when the navigation rail is collapsed.

| Parameters |
|---|---|
| `int itemSpacing` | the desired item spacing in between the items when the nav rail is collapsed |

### setExpandedItemMinimumHeight

```
public void setExpandedItemMinimumHeight(int minHeight)
```

Sets the minimum height of a navigation rail menu item when the navigation rail is expanded.

| Parameters |
|---|---|
| `int minHeight` | the min height of the item when the nav rail is collapsed |

### 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()` |   |

### setItemMinimumHeight

```
public void setItemMinimumHeight(int minHeight)
```

Set the minimum height each item in the navigation rail's menu should use.

If this is unset (-1), each item will be at least as tall as the navigation rail is wide.

### setItemSpacing

```
public void setItemSpacing(int itemSpacing)
```

Set the padding in between the navigation rail menu items.

### setMenuGravity

```
public void setMenuGravity(int gravity)
```

Sets how destinations in the menu view will be grouped.

### setSubmenuDividersEnabled

```
public void setSubmenuDividersEnabled(boolean submenuDividersEnabled)
```

Set whether or not to enable the dividers which go between each subgroup in the menu.

## Protected methods

### isSubMenuSupported

```
protected boolean isSubMenuSupported()
```

Returns whether or not submenus are supported.

### onMeasure

```
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
```