public class

ActionDrawer

extends Object
java.lang.Object
   ↳ com.droidux.ui.widgets.actiondrawer.ActionDrawer

Class Overview

A slide-out view, usually used to provide a menu of actions that allows users to switch between views of your app. Use the ActionDrawer.Builder class to build and customize the action drawer. You need to provide an implementation of the ActionDrawer.Callback interface that create the drawer's view and prepare the drawer's view before it is shown.

Summary

Nested Classes
class ActionDrawer.Builder Use this class to build and customize the action drawer. 
interface ActionDrawer.Callback Callback interface for action drawer. 
enum ActionDrawer.DrawerMode Determines whether the drawer will be overlaid by the activity's content (exclusive action bar) or the whole window (inclusive action bar)  
enum ActionDrawer.DrawerPosition Determines the position of the drawer. 
interface ActionDrawer.OnDrawerStateChangeListener Listener for receiving events when the action drawer state has changed. 
interface ActionDrawer.OnDrawingListener A listener to be notified when the drawer, content and arrow are being drawn. 
Constants
int STATE_DRAWER_CLOSED
int STATE_DRAWER_CLOSING
int STATE_DRAWER_DRAGGING
int STATE_DRAWER_OPEN
int STATE_DRAWER_OPENING
Public Methods
void closeDrawer()
Close the action drawer.
void closeDrawer(boolean animate)
Close the action drawer.
ViewGroup getContainer()
This method is deprecated. Use getParentContainer() instead.
ViewGroup getContainerForContent()
Returns the parent/container ViewGroup that contains the content view.
ViewGroup getContainerForDrawer()
Returns the parent/container ViewGroup that contains the drawer view.
boolean getDrawerEnabled()
Gets whether the drawer is enabled.
boolean getDrawerFadeEnabled()
Gets whether the drawer's fading/dimming effect is enabled.
ActionDrawer.DrawerMode getDrawerMode()
Returns the mode of the drawer.
ActionDrawer.DrawerPosition getDrawerPosition()
Returns the position of the drawer view.
int getDrawerState()
Gets the current state of the drawer.
ActionDrawer.OnDrawerStateChangeListener getOnDrawerStateChangeListener()
Returns the listener to be notified when the drawer state has changed.
ActionDrawer.OnDrawingListener getOnDrawingListener()
Gets the listener to be notified when various components of the drawer is being drawn.
boolean getParallaxEnabled()
Whether the drawer's parallax-scrolling effect is enabled.
float getParallaxFactor()
ViewGroup getParentContainer()
Returns the container view.
ViewGroup getWindowWrapper()
Gets the ViewGroup that wraps the original window layout.
boolean isDrawerLocked()
boolean isDrawerVisible()
Whether the drawer is visible or not.
void onRestoreInstanceState(Parcelable state)
Restore/re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().
Parcelable onSaveInstanceState()
Save the representation of its internal state that can later be used to create a new instance with that same state.
void openDrawer(boolean animate)
Opens the action drawer.
void openDrawer()
Opens the action drawer.
void setArrowAnchor(View anchor)
Call this method within the onPrepareDrawerView(View) to have an arrow pointed to the specified anchor view.
void setContentBackground(Drawable background)
Sets the content's background.
void setContentBackground(int backgroundResId)
Sets the content's background.
void setContentSlideEnabled(boolean enabled)
Enable/disable whether to slide the content along with the drawer.
void setDisableContentWhenDrawerVisible(boolean disable, boolean fadeContentWhenDisabled)
Disable/enable the content view when the drawer is visible.
void setDrawerBackground(Drawable background)
Sets the drawer's background.
void setDrawerBackground(int backgroundResId)
Sets the drawer's background.
void setDrawerEnabled(boolean enabled)
Enable/disable the drawer.
void setDrawerFadeEnabled(boolean enabled)
Enable/disable the fade/dim effect when the drawer is opening/closing.
void setDrawerLocked(boolean locked)
If locked, the drawer won't respond to touch gesture.
void setOnDrawerStateChangeListener(ActionDrawer.OnDrawerStateChangeListener listener)
Sets the listener to be notified when the drawer state has changed.
void setOnDrawingListener(ActionDrawer.OnDrawingListener listener)
Sets the listener to be notified when various components of the drawer is being drawn.
void setParallaxEnabled(boolean enabled)
Enables/disables parallax-scrolling effect.
void setParallaxFactor(float factor)
Set the factor to determine the initial offset of the position of the drawer when it's start opening.
void setScrimColor(int color)
Set a color to use for the scrim that obscures the content/drawer when the drawer is open.
void toggleDrawer()
If the drawer is closed, it will be opened.
void toggleDrawer(boolean animated)
If the drawer is closed, it will be opened.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int STATE_DRAWER_CLOSED

Since: API Level 3.0

Constant Value: 0 (0x00000000)

public static final int STATE_DRAWER_CLOSING

Since: API Level 3.0

Constant Value: 1 (0x00000001)

public static final int STATE_DRAWER_DRAGGING

Since: API Level 3.0

Constant Value: 2 (0x00000002)

public static final int STATE_DRAWER_OPEN

Since: API Level 3.0

Constant Value: 4 (0x00000004)

public static final int STATE_DRAWER_OPENING

Since: API Level 3.0

Constant Value: 3 (0x00000003)

Public Methods

public void closeDrawer ()

Since: API Level 3.0

Close the action drawer.

public void closeDrawer (boolean animate)

Since: API Level 3.0

Close the action drawer.

Parameters
animate If true, the drawer will be animated.

public ViewGroup getContainer ()

Since: API Level 3.0

This method is deprecated.
Use getParentContainer() instead.

Returns the container view. This container view is a parent ViewGroup that contains both the drawer's container and the content's container. If you need to work with the container that contains only the drawer, use the getContainerForDrawer() method instead. If you need to work with the container that contains only the content view, use the getContainerForContent() method instead.

public ViewGroup getContainerForContent ()

Since: API Level 3.0

Returns the parent/container ViewGroup that contains the content view.

public ViewGroup getContainerForDrawer ()

Since: API Level 3.0

Returns the parent/container ViewGroup that contains the drawer view.

public boolean getDrawerEnabled ()

Since: API Level 3.0

Gets whether the drawer is enabled.

Returns
  • true if enabled.

public boolean getDrawerFadeEnabled ()

Since: API Level 3.0

Gets whether the drawer's fading/dimming effect is enabled.

Returns
  • true when the effect is enabled, false otherwise.

public ActionDrawer.DrawerMode getDrawerMode ()

Since: API Level 3.0

Returns the mode of the drawer. Can be one of WINDOW_OVERLAY or CONTENT_OVERLAY.

public ActionDrawer.DrawerPosition getDrawerPosition ()

Since: API Level 3.0

Returns the position of the drawer view. Can be either LEFT or RIGHT

public int getDrawerState ()

Since: API Level 3.0

Gets the current state of the drawer. Possible states are: STATE_DRAWER_CLOSED, STATE_DRAWER_CLOSING, STATE_DRAWER_OPEN, STATE_DRAWER_OPENING, STATE_DRAWER_DRAGGING.

Returns
  • The current state of the drawer.

public ActionDrawer.OnDrawerStateChangeListener getOnDrawerStateChangeListener ()

Since: API Level 3.0

Returns the listener to be notified when the drawer state has changed.

Returns
  • null if no listener has been set, or the listener.

public ActionDrawer.OnDrawingListener getOnDrawingListener ()

Since: API Level 3.0

Gets the listener to be notified when various components of the drawer is being drawn.

Returns
  • The listener to be notified.

public boolean getParallaxEnabled ()

Since: API Level 3.0

Whether the drawer's parallax-scrolling effect is enabled.

Returns
  • true if the parallax-scrolling effect is enabled.

public float getParallaxFactor ()

Since: API Level 3.0

public ViewGroup getParentContainer ()

Since: API Level 3.1

Returns the container view. This container view is a parent ViewGroup that contains both the drawer's container and the content's container. If you need to work with the container that contains only the drawer, use the getContainerForDrawer() method instead. If you need to work with the container that contains only the content view, use the getContainerForContent() method instead.

public ViewGroup getWindowWrapper ()

Since: API Level 3.0

Gets the ViewGroup that wraps the original window layout. This will return the layout set by setWindowWrapperLayout(int). The window wrapper is only valid if the setDrawerMode(ActionDrawer.DrawerMode) is set to WINDOW_OVERLAY.

Returns

public boolean isDrawerLocked ()

Since: API Level 3.1

Returns
  • Whether the drawer is locked.

public boolean isDrawerVisible ()

Since: API Level 3.0

Whether the drawer is visible or not.

Returns
  • true if the drawer is visible.

public void onRestoreInstanceState (Parcelable state)

Since: API Level 3.0

Restore/re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().

Note: If the drawer's mode is CONTENT_OVERLAY the state will be restored automatically. However, if the drawer's mode is WINDOW_OVERLAY, you need to call this method manually to restore the state (e.g. in onRestoreInstanceState(android.os.Bundle))

Parameters
state The state to restored.

public Parcelable onSaveInstanceState ()

Since: API Level 3.0

Save the representation of its internal state that can later be used to create a new instance with that same state.

Note: If the drawer's mode is CONTENT_OVERLAY, and isSaveEnabled() is true, the state will be saved automatically. However, if the drawer's mode is WINDOW_OVERLAY, you need to call this method manually to save the state (e.g. in onSaveInstanceState(android.os.Bundle))

Returns
  • The representation of the internal state.

public void openDrawer (boolean animate)

Since: API Level 3.0

Opens the action drawer.

Parameters
animate If true, the drawer will be animated.

public void openDrawer ()

Since: API Level 3.0

Opens the action drawer.

public void setArrowAnchor (View anchor)

Since: API Level 3.0

Call this method within the onPrepareDrawerView(View) to have an arrow pointed to the specified anchor view. Normally you do this if you want to highlight the selected item within the action drawer.

Parameters
anchor The view onto which the arrow should point.

public void setContentBackground (Drawable background)

Since: API Level 3.0

Sets the content's background.

Parameters
background The Drawable to use as the background, or null to remove the background.

public void setContentBackground (int backgroundResId)

Since: API Level 3.0

Sets the content's background. The resource should refer to a Drawable, or 0 to remove the background.

Parameters
backgroundResId The identifier of the resource

public void setContentSlideEnabled (boolean enabled)

Since: API Level 3.0

Enable/disable whether to slide the content along with the drawer.

Parameters
enabled If true the content will slide while the drawer is opening/closing. Default is true.

public void setDisableContentWhenDrawerVisible (boolean disable, boolean fadeContentWhenDisabled)

Since: API Level 3.0

Disable/enable the content view when the drawer is visible.

Parameters
disable If true, the content view will be disabled (no interaction) when the drawer is visible/opened. Otherwise, you can still interact with the content when the drawer is visible/opened.
fadeContentWhenDisabled If true, the content view will be dimmed/faded when the content is disabled. Otherwise, no dim/fade effect will be applied.

public void setDrawerBackground (Drawable background)

Since: API Level 3.0

Sets the drawer's background.

Parameters
background The Drawable to use as the background, or null to remove the background.

public void setDrawerBackground (int backgroundResId)

Since: API Level 3.0

Sets the drawer's background. The resource should refer to a Drawable, or 0 to remove the background.

Parameters
backgroundResId The identifier of the resource

public void setDrawerEnabled (boolean enabled)

Since: API Level 3.0

Enable/disable the drawer. If disabled, the drawer can't be opened.

Parameters
enabled If true, the drawer behave normally. Otherwise, the drawer can't be opened.

public void setDrawerFadeEnabled (boolean enabled)

Since: API Level 3.0

Enable/disable the fade/dim effect when the drawer is opening/closing.

Parameters
enabled If true, the drawer will have a fade/dimmed effect when it's opening/closing.

public void setDrawerLocked (boolean locked)

Since: API Level 3.1

If locked, the drawer won't respond to touch gesture.

public void setOnDrawerStateChangeListener (ActionDrawer.OnDrawerStateChangeListener listener)

Since: API Level 3.0

Sets the listener to be notified when the drawer state has changed.

Parameters
listener The listener to be notified.

public void setOnDrawingListener (ActionDrawer.OnDrawingListener listener)

Since: API Level 3.0

Sets the listener to be notified when various components of the drawer is being drawn.

Parameters
listener The listener to be notified.

public void setParallaxEnabled (boolean enabled)

Since: API Level 3.0

Enables/disables parallax-scrolling effect.

Parameters
enabled If true, the parallax-scrolling effect will be enabled. Otherwise, disabled.

public void setParallaxFactor (float factor)

Since: API Level 3.0

Set the factor to determine the initial offset of the position of the drawer when it's start opening. When the factor is set to 0.0f, the initial position of the drawer will be the same as the final position (no offset). When the factor is set to 1.0f (full offset), the drawer will be initially positioned at the edge of the screen. With factor between 0.0f - 1.0f, the drawer will initially be positioned in between the edge of the screen and its final position.

Parameters
factor Value must be between 0.0f - 1.0f. Default is 0.25f

public void setScrimColor (int color)

Since: API Level 3.1

Set a color to use for the scrim that obscures the content/drawer when the drawer is open.

Parameters
color Color to use in 0xAARRGGBB format.

public void toggleDrawer ()

Since: API Level 3.0

If the drawer is closed, it will be opened. And vice versa, if it's currently opened, it will be closed.

public void toggleDrawer (boolean animated)

Since: API Level 3.0

If the drawer is closed, it will be opened. And vice versa, if it's currently opened, it will be closed.

Parameters
animated If true, the drawer will be animated.