Navigation Rail View
Represents a standard navigation rail view for application. It is an implementation of Material Design 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 , 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 and design guidelines.