Navigation View
(SESL Variant) Represents a standard navigation menu for application. The menu contents can be populated by a menu resource file.
NavigationView is typically placed inside a androidx.drawerlayout.widget.DrawerLayout.
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Your contents -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/my_navigation_items" />
</androidx.drawerlayout.widget.DrawerLayout>
Content copied to clipboard
Types
Link copied to clipboard
interface OnNavigationItemSelectedListener
Listener for handling events on navigation items.
Link copied to clipboard
User interface state that is stored by NavigationView for implementing onSaveInstanceState().
Functions
Link copied to clipboard
Adds a View as a header of the navigation menu.
Link copied to clipboard
Returns the currently checked item in this navigation menu.
Link copied to clipboard
Gets the number of headers in this NavigationView.
Link copied to clipboard
Gets the header view at the specified position.
Link copied to clipboard
Returns the background drawable for our menu items.
Link copied to clipboard
Returns the horizontal (left and right) padding in pixels applied to menu items.
Link copied to clipboard
Returns the padding in pixels between the icon (if present) and the text of menu items.
Link copied to clipboard
Returns the tint which is applied to our menu items' icons.
Link copied to clipboard
Gets the android:maxLines attribute of the text view in the menu item.
Link copied to clipboard
Returns the tint which is applied to our menu items' icons.
Link copied to clipboard
Inflates a View and add it as a header of the navigation menu.
Link copied to clipboard
Inflate a menu resource into this navigation view.
Link copied to clipboard
Removes a previously-added header view.
Link copied to clipboard
Sets the currently checked item in this navigation menu.
Link copied to clipboard
Link copied to clipboard
Set the background of our menu items to a given resource.
Link copied to clipboard
Set the background of our menu items to the given resource.
Link copied to clipboard
Set the horizontal (left and right) padding in pixels of menu items.
Link copied to clipboard
Set the horizontal (left and right) padding of menu items.
Link copied to clipboard
Set the padding in pixels between the icon (if present) and the text of menu items.
Link copied to clipboard
Set the padding between the icon (if present) and the text of menu items.
Link copied to clipboard
Sets the size to be used for the menu item icons in pixels.
Link copied to clipboard
Set the tint which is applied to our menu items' icons.
Link copied to clipboard
Sets the android:maxLines attribute of the text view in the menu item.
Link copied to clipboard
Set the text appearance of the menu items to a given resource.
Link copied to clipboard
Set the text color to be used on our menu items.
Link copied to clipboard
open fun setNavigationItemSelectedListener(@Nullable listener: NavigationView.OnNavigationItemSelectedListener)
Set a listener that will be notified when a menu item is selected.
Link copied to clipboard