android.support.v4.widget
Class DrawerLayout

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.support.v4.widget.DrawerLayout
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.view.accessibility.AccessibilityEventSource, android.view.KeyEvent.Callback, android.view.ViewManager, android.view.ViewParent

public class DrawerLayout
extends android.view.ViewGroup

DrawerLayout acts as a top-level container for window content that allows for interactive "drawer" views to be pulled out from the edge of the window.

Drawer positioning and layout is controlled using the android:layout_gravity attribute on child views corresponding to which side of the view you want the drawer to emerge from: left or right. (Or start/end on platform versions that support layout direction.)

To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width.

DrawerLayout.DrawerListener can be used to monitor the state and motion of drawer views. Avoid performing expensive operations such as layout during animation as it can cause stuttering; try to perform expensive operations during the STATE_IDLE state. DrawerLayout.SimpleDrawerListener offers default/no-op implementations of each callback method.

As per the Android Design guide, any drawers positioned to the left/start should always contain content for navigating around the application, whereas any drawers positioned to the right/end should always contain actions to take on the current content. This preserves the same navigation left, actions right structure present in the Action Bar and elsewhere.


Nested Class Summary
static interface DrawerLayout.DrawerListener
          Listener for monitoring events about drawers.
static class DrawerLayout.LayoutParams
           
protected static class DrawerLayout.SavedState
          State persisted across instances
static class DrawerLayout.SimpleDrawerListener
          Stub/no-op implementations of all methods of DrawerLayout.DrawerListener.
 
Nested classes/interfaces inherited from class android.view.ViewGroup
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnAttachStateChangeListener, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener
 
Field Summary
static int LOCK_MODE_LOCKED_CLOSED
          The drawer is locked closed.
static int LOCK_MODE_LOCKED_OPEN
          The drawer is locked open.
static int LOCK_MODE_UNLOCKED
          The drawer is unlocked.
static int STATE_DRAGGING
          Indicates that a drawer is currently being dragged by the user.
static int STATE_IDLE
          Indicates that any drawers are in an idle, settled state.
static int STATE_SETTLING
          Indicates that a drawer is in the process of settling to a final position.
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
ALPHA, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y
 
Constructor Summary
DrawerLayout(android.content.Context context)
           
DrawerLayout(android.content.Context context, android.util.AttributeSet attrs)
           
DrawerLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
           
 
Method Summary
protected  boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
           
 void closeDrawer(int gravity)
          Close the specified drawer by animating it out of view.
 void closeDrawer(android.view.View drawerView)
          Close the specified drawer view by animating it into view.
 void closeDrawers()
          Close all currently open drawer views by animating them out of view.
 void computeScroll()
           
protected  boolean drawChild(android.graphics.Canvas canvas, android.view.View child, long drawingTime)
           
protected  android.view.ViewGroup.LayoutParams generateDefaultLayoutParams()
           
 android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
           
protected  android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p)
           
 int getDrawerLockMode(int edgeGravity)
          Check the lock mode of the drawer with the given gravity.
 int getDrawerLockMode(android.view.View drawerView)
          Check the lock mode of the given drawer view.
 boolean isDrawerOpen(int drawerGravity)
          Check if the given drawer view is currently in an open state.
 boolean isDrawerOpen(android.view.View drawer)
          Check if the given drawer view is currently in an open state.
 boolean isDrawerVisible(int drawerGravity)
          Check if a given drawer view is currently visible on-screen.
 boolean isDrawerVisible(android.view.View drawer)
          Check if a given drawer view is currently visible on-screen.
protected  void onAttachedToWindow()
           
protected  void onDetachedFromWindow()
           
 boolean onInterceptTouchEvent(android.view.MotionEvent ev)
           
 boolean onKeyDown(int keyCode, android.view.KeyEvent event)
           
 boolean onKeyUp(int keyCode, android.view.KeyEvent event)
           
protected  void onLayout(boolean changed, int l, int t, int r, int b)
           
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           
protected  void onRestoreInstanceState(android.os.Parcelable state)
           
protected  android.os.Parcelable onSaveInstanceState()
           
 boolean onTouchEvent(android.view.MotionEvent ev)
           
 void openDrawer(int gravity)
          Open the specified drawer by animating it out of view.
 void openDrawer(android.view.View drawerView)
          Open the specified drawer view by animating it into view.
 void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
           
 void requestLayout()
           
 void setDrawerListener(DrawerLayout.DrawerListener listener)
          Set a listener to be notified of drawer events.
 void setDrawerLockMode(int lockMode)
          Enable or disable interaction with all drawers.
 void setDrawerLockMode(int lockMode, int edgeGravity)
          Enable or disable interaction with the given drawer.
 void setDrawerLockMode(int lockMode, android.view.View drawerView)
          Enable or disable interaction with the given drawer.
 void setDrawerShadow(android.graphics.drawable.Drawable shadowDrawable, int gravity)
          Set a simple drawable used for the left or right shadow.
 void setDrawerShadow(int resId, int gravity)
          Set a simple drawable used for the left or right shadow.
 void setScrimColor(int color)
          Set a color to use for the scrim that obscures primary content while a drawer is open.
 
Methods inherited from class android.view.ViewGroup
addChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, endViewTransition, findFocus, findViewsWithText, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutTransition, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isMotionEventSplittingEnabled, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptHoverEvent, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayout
 
Methods inherited from class android.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchPopulateAccessibilityEvent, draw, findViewById, findViewWithTag, focusSearch, forceLayout, generateViewId, getAccessibilityNodeProvider, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hasOnClickListeners, hasOverlappingRendering, hasTransientState, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDraw, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onOverScrolled, onPopulateAccessibilityEvent, onRtlPropertiesChanged, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, startActionMode, startAnimation, startDrag, toString, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, getParentForAccessibility, isLayoutRequested, requestFitSystemWindows
 

Field Detail

STATE_IDLE

public static final int STATE_IDLE
Indicates that any drawers are in an idle, settled state. No animation is in progress.

See Also:
Constant Field Values

STATE_DRAGGING

public static final int STATE_DRAGGING
Indicates that a drawer is currently being dragged by the user.

See Also:
Constant Field Values

STATE_SETTLING

public static final int STATE_SETTLING
Indicates that a drawer is in the process of settling to a final position.

See Also:
Constant Field Values

LOCK_MODE_UNLOCKED

public static final int LOCK_MODE_UNLOCKED
The drawer is unlocked.

See Also:
Constant Field Values

LOCK_MODE_LOCKED_CLOSED

public static final int LOCK_MODE_LOCKED_CLOSED
The drawer is locked closed. The user may not open it, though the app may open it programmatically.

See Also:
Constant Field Values

LOCK_MODE_LOCKED_OPEN

public static final int LOCK_MODE_LOCKED_OPEN
The drawer is locked open. The user may not close it, though the app may close it programmatically.

See Also:
Constant Field Values
Constructor Detail

DrawerLayout

public DrawerLayout(android.content.Context context)

DrawerLayout

public DrawerLayout(android.content.Context context,
                    android.util.AttributeSet attrs)

DrawerLayout

public DrawerLayout(android.content.Context context,
                    android.util.AttributeSet attrs,
                    int defStyle)
Method Detail

setDrawerShadow

public void setDrawerShadow(android.graphics.drawable.Drawable shadowDrawable,
                            int gravity)
Set a simple drawable used for the left or right shadow. The drawable provided must have a nonzero intrinsic width.

Parameters:
shadowDrawable - Shadow drawable to use at the edge of a drawer
gravity - Which drawer the shadow should apply to

setDrawerShadow

public void setDrawerShadow(int resId,
                            int gravity)
Set a simple drawable used for the left or right shadow. The drawable provided must have a nonzero intrinsic width.

Parameters:
resId - Resource id of a shadow drawable to use at the edge of a drawer
gravity - Which drawer the shadow should apply to

setScrimColor

public void setScrimColor(int color)
Set a color to use for the scrim that obscures primary content while a drawer is open.

Parameters:
color - Color to use in 0xAARRGGBB format.

setDrawerListener

public void setDrawerListener(DrawerLayout.DrawerListener listener)
Set a listener to be notified of drawer events.

Parameters:
listener - Listener to notify when drawer events occur
See Also:
DrawerLayout.DrawerListener

setDrawerLockMode

public void setDrawerLockMode(int lockMode)
Enable or disable interaction with all drawers.

This allows the application to restrict the user's ability to open or close any drawer within this layout. DrawerLayout will still respond to calls to openDrawer(int), closeDrawer(int) and friends if a drawer is locked.

Locking drawers open or closed will implicitly open or close any drawers as appropriate.

Parameters:
lockMode - The new lock mode for the given drawer. One of LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED or LOCK_MODE_LOCKED_OPEN.

setDrawerLockMode

public void setDrawerLockMode(int lockMode,
                              int edgeGravity)
Enable or disable interaction with the given drawer.

This allows the application to restrict the user's ability to open or close the given drawer. DrawerLayout will still respond to calls to openDrawer(int), closeDrawer(int) and friends if a drawer is locked.

Locking a drawer open or closed will implicitly open or close that drawer as appropriate.

Parameters:
lockMode - The new lock mode for the given drawer. One of LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED or LOCK_MODE_LOCKED_OPEN.
edgeGravity - Gravity.LEFT, RIGHT, START or END. Expresses which drawer to change the mode for.
See Also:
LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED, LOCK_MODE_LOCKED_OPEN

setDrawerLockMode

public void setDrawerLockMode(int lockMode,
                              android.view.View drawerView)
Enable or disable interaction with the given drawer.

This allows the application to restrict the user's ability to open or close the given drawer. DrawerLayout will still respond to calls to openDrawer(int), closeDrawer(int) and friends if a drawer is locked.

Locking a drawer open or closed will implicitly open or close that drawer as appropriate.

Parameters:
lockMode - The new lock mode for the given drawer. One of LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED or LOCK_MODE_LOCKED_OPEN.
drawerView - The drawer view to change the lock mode for
See Also:
LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED, LOCK_MODE_LOCKED_OPEN

getDrawerLockMode

public int getDrawerLockMode(int edgeGravity)
Check the lock mode of the drawer with the given gravity.

Parameters:
edgeGravity - Gravity of the drawer to check
Returns:
one of LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED or LOCK_MODE_LOCKED_OPEN.

getDrawerLockMode

public int getDrawerLockMode(android.view.View drawerView)
Check the lock mode of the given drawer view.

Parameters:
drawerView - Drawer view to check lock mode
Returns:
one of LOCK_MODE_UNLOCKED, LOCK_MODE_LOCKED_CLOSED or LOCK_MODE_LOCKED_OPEN.

onDetachedFromWindow

protected void onDetachedFromWindow()
Overrides:
onDetachedFromWindow in class android.view.View

onAttachedToWindow

protected void onAttachedToWindow()
Overrides:
onAttachedToWindow in class android.view.View

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Overrides:
onMeasure in class android.view.View

onLayout

protected void onLayout(boolean changed,
                        int l,
                        int t,
                        int r,
                        int b)
Specified by:
onLayout in class android.view.ViewGroup

requestLayout

public void requestLayout()
Specified by:
requestLayout in interface android.view.ViewParent
Overrides:
requestLayout in class android.view.View

computeScroll

public void computeScroll()
Overrides:
computeScroll in class android.view.View

drawChild

protected boolean drawChild(android.graphics.Canvas canvas,
                            android.view.View child,
                            long drawingTime)
Overrides:
drawChild in class android.view.ViewGroup

onInterceptTouchEvent

public boolean onInterceptTouchEvent(android.view.MotionEvent ev)
Overrides:
onInterceptTouchEvent in class android.view.ViewGroup

onTouchEvent

public boolean onTouchEvent(android.view.MotionEvent ev)
Overrides:
onTouchEvent in class android.view.View

requestDisallowInterceptTouchEvent

public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Specified by:
requestDisallowInterceptTouchEvent in interface android.view.ViewParent
Overrides:
requestDisallowInterceptTouchEvent in class android.view.ViewGroup

closeDrawers

public void closeDrawers()
Close all currently open drawer views by animating them out of view.


openDrawer

public void openDrawer(android.view.View drawerView)
Open the specified drawer view by animating it into view.

Parameters:
drawerView - Drawer view to open

openDrawer

public void openDrawer(int gravity)
Open the specified drawer by animating it out of view.

Parameters:
gravity - Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right. GravityCompat.START or GravityCompat.END may also be used.

closeDrawer

public void closeDrawer(android.view.View drawerView)
Close the specified drawer view by animating it into view.

Parameters:
drawerView - Drawer view to close

closeDrawer

public void closeDrawer(int gravity)
Close the specified drawer by animating it out of view.

Parameters:
gravity - Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right. GravityCompat.START or GravityCompat.END may also be used.

isDrawerOpen

public boolean isDrawerOpen(android.view.View drawer)
Check if the given drawer view is currently in an open state. To be considered "open" the drawer must have settled into its fully visible state. To check for partial visibility use isDrawerVisible(android.view.View).

Parameters:
drawer - Drawer view to check
Returns:
true if the given drawer view is in an open state
See Also:
isDrawerVisible(android.view.View)

isDrawerOpen

public boolean isDrawerOpen(int drawerGravity)
Check if the given drawer view is currently in an open state. To be considered "open" the drawer must have settled into its fully visible state. If there is no drawer with the given gravity this method will return false.

Parameters:
drawerGravity - Gravity of the drawer to check
Returns:
true if the given drawer view is in an open state

isDrawerVisible

public boolean isDrawerVisible(android.view.View drawer)
Check if a given drawer view is currently visible on-screen. The drawer may be only peeking onto the screen, fully extended, or anywhere inbetween.

Parameters:
drawer - Drawer view to check
Returns:
true if the given drawer is visible on-screen
See Also:
isDrawerOpen(android.view.View)

isDrawerVisible

public boolean isDrawerVisible(int drawerGravity)
Check if a given drawer view is currently visible on-screen. The drawer may be only peeking onto the screen, fully extended, or anywhere inbetween. If there is no drawer with the given gravity this method will return false.

Parameters:
drawerGravity - Gravity of the drawer to check
Returns:
true if the given drawer is visible on-screen

generateDefaultLayoutParams

protected android.view.ViewGroup.LayoutParams generateDefaultLayoutParams()
Overrides:
generateDefaultLayoutParams in class android.view.ViewGroup

generateLayoutParams

protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p)
Overrides:
generateLayoutParams in class android.view.ViewGroup

checkLayoutParams

protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
Overrides:
checkLayoutParams in class android.view.ViewGroup

generateLayoutParams

public android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
Overrides:
generateLayoutParams in class android.view.ViewGroup

onKeyDown

public boolean onKeyDown(int keyCode,
                         android.view.KeyEvent event)
Specified by:
onKeyDown in interface android.view.KeyEvent.Callback
Overrides:
onKeyDown in class android.view.View

onKeyUp

public boolean onKeyUp(int keyCode,
                       android.view.KeyEvent event)
Specified by:
onKeyUp in interface android.view.KeyEvent.Callback
Overrides:
onKeyUp in class android.view.View

onRestoreInstanceState

protected void onRestoreInstanceState(android.os.Parcelable state)
Overrides:
onRestoreInstanceState in class android.view.View

onSaveInstanceState

protected android.os.Parcelable onSaveInstanceState()
Overrides:
onSaveInstanceState in class android.view.View


Copyright © 2013 Marek Kedzierski. All Rights Reserved.