ActionBarDrawerToggle

This class provides a handy way to tie together the functionality of DrawerLayout and the framework ActionBar to implement the recommended design for navigation drawers.

To use ActionBarDrawerToggle, create one in your Activity and call through to the following methods corresponding to your Activity callbacks:

Call syncState from your Activity's onPostCreate to synchronize the indicator with the state of the linked DrawerLayout after onRestoreInstanceState has occurred.

ActionBarDrawerToggle can be used directly as a DrawerLayout.DrawerListener, or if you are already providing your own listener, call through to each of the listener methods from your own.

You can customize the the animated toggle by defining the drawerArrowStyle in your ActionBar theme.

Constructors

Link copied to clipboard
constructor(activity: Activity, drawerLayout: DrawerLayout, @StringRes openDrawerContentDescRes: Int, @StringRes closeDrawerContentDescRes: Int)
Construct a new ActionBarDrawerToggle.
constructor(activity: Activity, drawerLayout: DrawerLayout, toolbar: Toolbar, @StringRes openDrawerContentDescRes: Int, @StringRes closeDrawerContentDescRes: Int)
Construct a new ActionBarDrawerToggle with a Toolbar.

Types

Link copied to clipboard
interface Delegate
Link copied to clipboard
Allows an implementing Activity to return an ActionBarDrawerToggle.Delegate to use with ActionBarDrawerToggle.

Functions

Link copied to clipboard
@NonNull
open fun getDrawerArrowDrawable(): @NonNull DrawerArrowDrawable
Link copied to clipboard
Returns the fallback listener for Navigation icon click events.
Link copied to clipboard
Link copied to clipboard
This method should always be called by your Activity's onConfigurationChanged method.
Link copied to clipboard
open fun onDrawerClosed(drawerView: View)
Link copied to clipboard
open fun onDrawerOpened(drawerView: View)
Link copied to clipboard
open fun onDrawerSlide(drawerView: View, slideOffset: Float)
Link copied to clipboard
open fun onDrawerStateChanged(newState: Int)
Link copied to clipboard
This method should be called by your Activity's onOptionsItemSelected method.
Link copied to clipboard
open fun setDrawerArrowDrawable(@NonNull drawable: @NonNull DrawerArrowDrawable)
Sets the DrawerArrowDrawable that should be shown by this ActionBarDrawerToggle.
Link copied to clipboard
Enable or disable the drawer indicator.
Link copied to clipboard
Specifies whether the drawer arrow should animate when the drawer position changes.
Link copied to clipboard
open fun setHomeAsUpIndicator(indicator: Drawable)
open fun setHomeAsUpIndicator(resId: Int)
Set the up indicator to display when the drawer indicator is not enabled.
Link copied to clipboard
open fun setToolbarNavigationClickListener(onToolbarNavigationClickListener: View.OnClickListener)
When DrawerToggle is constructed with a Toolbar, it sets the click listener on the Navigation icon.
Link copied to clipboard
open fun syncState()
Synchronize the state of the drawer indicator/affordance with the linked DrawerLayout.