DrawerLayout

class DrawerLayout : ViewGroup, Openable


DrawerLayout acts as a top-level container for window content that allows for interactive "drawer" views to be pulled out from one or both vertical edges 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.) Note that you can only have one drawer view for each vertical edge of the window. If your layout configures more than one drawer view per vertical edge of the window, an exception will be thrown at runtime.

To use a DrawerLayout, position your primary content view as the first child with width and height of match_parent and no layout_gravity>. 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.

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. 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.

For more information about how to use DrawerLayout, read Creating a Navigation Drawer.

Summary

Nested types

Listener for monitoring events about drawers.

State persisted across instances

Stub/no-op implementations of all methods of DrawerListener.

Constants

const Int

The drawer is locked closed.

const Int

The drawer is locked open.

const Int

The drawer's lock state is reset to default.

const Int

The drawer is unlocked.

const Int

Indicates that a drawer is currently being dragged by the user.

const Int

Indicates that any drawers are in an idle, settled state.

const Int

Indicates that a drawer is in the process of settling to a final position.

Public constructors

DrawerLayout(context: Context, attrs: AttributeSet?)
DrawerLayout(context: Context, attrs: AttributeSet?, defStyleAttr: Int)

Public functions

Unit

Adds the specified listener to the list of listeners that will be notified of drawer events.

Unit
addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int)
Unit
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit

Close the START drawer by animating it out of view.

Unit
closeDrawer(drawerView: View)

Close the specified drawer view by animating it into view.

Unit

Close the specified drawer by animating it out of view.

Unit
closeDrawer(drawerView: View, animate: Boolean)

Close the specified drawer view.

Unit

Close the specified drawer.

Unit

Close all currently open drawer views by animating them out of view.

Unit
Boolean
ViewGroup.LayoutParams!
Float

The base elevation of the drawer(s) relative to the parent, in pixels.

Int

Check the lock mode of the given drawer view.

Int

Check the lock mode of the drawer with the given gravity.

CharSequence?

Returns the title of the drawer with the given gravity.

Drawable?

Gets the drawable used to draw in the insets area for the status bar.

Boolean

Check if the given drawer view is currently in an open state.

Boolean
isDrawerOpen(drawer: View)

Check if the given drawer view is currently in an open state.

Boolean

Check if a given drawer view is currently visible on-screen.

Boolean

Check if a given drawer view is currently visible on-screen.

Boolean

Check if the START drawer is currently in an open state.

Unit
Boolean
Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)
Unit
onRtlPropertiesChanged(layoutDirection: Int)
Boolean
Unit

Open the START drawer by animating it into view.

Unit
openDrawer(drawerView: View)

Open the specified drawer view by animating it into view.

Unit

Open the specified drawer by animating it out of view.

Unit
openDrawer(drawerView: View, animate: Boolean)

Open the specified drawer view.

Unit

Open the specified drawer.

Unit

Removes the specified listener from the list of listeners that will be notified of drawer events.

Unit
Unit
Unit

Sets the base elevation of the drawer(s) relative to the parent, in pixels.

Unit

This function is deprecated.

Use addDrawerListener

Unit

Enable or disable interaction with all drawers.

Unit
setDrawerLockMode(@DrawerLayout.LockMode lockMode: Int, drawerView: View)

Enable or disable interaction with the given drawer.

Unit
setDrawerLockMode(
    @DrawerLayout.LockMode lockMode: Int,
    @DrawerLayout.EdgeGravity edgeGravity: Int
)

Enable or disable interaction with the given drawer.

Unit
setDrawerShadow(
    resId: @DrawableRes Int,
    @DrawerLayout.EdgeGravity gravity: Int
)

Set a simple drawable used for the left or right shadow.

Unit
setDrawerShadow(
    shadowDrawable: Drawable?,
    @DrawerLayout.EdgeGravity gravity: Int
)

Set a simple drawable used for the left or right shadow.

Unit
setDrawerTitle(
    @DrawerLayout.EdgeGravity edgeGravity: Int,
    title: CharSequence?
)

Sets the title of the drawer with the given gravity.

Unit

Set a color to use for the scrim that obscures primary content while a drawer is open.

Unit

Set a drawable to draw in the insets area for the status bar.

Unit

Set a drawable to draw in the insets area for the status bar.

Unit

Set a drawable to draw in the insets area for the status bar.

Inherited Constants

From android.view.View
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Int
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
const String!
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
const String!
const String!
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
const String!
const String!
const String!
const String!
const String!
const String!
const String!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
GONE = 8
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
KEEP_SCREEN_ON = 67108864
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
NO_ID = -1
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const IntArray<Int>!
const IntArray<Int>!
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const String!
VIEW_LOG_TAG = "View"
const Int
const IntArray<Int>!
const Property<View!, Float!>!
const Property<View!, Float!>!
const Property<View!, Float!>!
From android.view.ViewGroup
const Int
const Int
const Int
const Int
const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

const Int

This property is deprecated.

Inherited functions

From android.view.View
Unit
Unit
Unit
ViewPropertyAnimator!
Unit
Unit
Boolean
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Boolean
Unit
Unit
java-static Int
combineMeasuredStates(curState: Int, newState: Int)
Int
Int
Int
WindowInsets!
computeSystemWindowInsets(in: WindowInsets!, outLocalInsets: Rect!)
Int
Int
Int
AccessibilityNodeInfo!
Unit
Unit

This function is deprecated.

Boolean
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Boolean
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
Boolean
dispatchNestedPrePerformAccessibilityAction(
    action: Int,
    arguments: Bundle!
)
Boolean
dispatchNestedPreScroll(
    dx: Int,
    dy: Int,
    consumed: IntArray!,
    offsetInWindow: IntArray!
)
Boolean
dispatchNestedScroll(
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    offsetInWindow: IntArray!
)
Boolean
Unit
draw(canvas: Canvas!)
Unit
OnBackInvokedDispatcher!
T!
<T : View?> findViewById(id: Int)
T!
<T : View?> findViewWithTag(tag: Any!)
Boolean

This function is deprecated.

Unit
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Unit
Unit
generateDisplayHash(
    hashAlgorithm: String!,
    bounds: Rect!,
    executor: Executor!,
    callback: DisplayHashResultCallback!
)
java-static Int
View.AccessibilityDelegate!
Int
AccessibilityNodeProvider!
CharSequence!
Int
Int
String!
String!
Float
Animation!
Matrix!
IBinder!
IntArray<Int>!
(Mutable)Map<Int!, Int!>!
Array<String!>!
AutofillId!
Int
AutofillValue!
Drawable!
BlendMode!
ColorStateList!
PorterDuff.Mode!
Int
Int
Float
Int
Float
Rect!
Boolean
getClipBounds(outRect: Rect!)
Boolean
ContentCaptureSession!
CharSequence!
Context!
ContextMenu.ContextMenuInfo!
Boolean
java-static Int
getDefaultSize(size: Int, measureSpec: Int)
Display!
IntArray<Int>!
Bitmap!

This function is deprecated.

Int

This function is deprecated.

Int

This function is deprecated.

Unit
getDrawingRect(outRect: Rect!)
Long
Float
Int
Boolean
Boolean
Int
ArrayList<View!>!
getFocusables(direction: Int)
Unit
Drawable!
Int
BlendMode!
ColorStateList!
PorterDuff.Mode!
Boolean
getGlobalVisibleRect(r: Rect!, globalOffset: Point!)
Handler!
Float
Float
Float
Float
Runnable!
Boolean
Int
Unit
getHitRect(outRect: Rect!)
Int
Int
Drawable!
Drawable!
Int
Int
Int
Int
Boolean
KeyEvent.DispatcherState!
Int
Int
Int
ViewGroup.LayoutParams!
Int
Float
Int
Boolean
Unit
Unit
Unit
Matrix!
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
View.OnFocusChangeListener!
Int
ViewOutlineProvider!
Int
Int
ViewOverlay!
Int
Int
Int
Int
Int
Int
ViewParent!
ViewParent!
Float
Float
PointerIcon!
(Mutable)List<Rect!>!
Array<String!>!
Resources!
Boolean
Int
Float
Int
AttachedSurfaceControl!
View!
WindowInsets!
Float
Float
Float
Float
Float
Int
Int
Int
Int
Int
Int
Int
Int
Int
Int
CharSequence!
StateListAnimator!
Int
Int
(Mutable)List<Rect!>!
Int

This function is deprecated.

Any!
Int
Int
CharSequence!
Int
Float
Int
TouchDelegate!
ArrayList<View!>!
Float
String!
Float
Float
Float
Long
Int
Int
Drawable!
Drawable!
Int
ViewTranslationResponse!
ViewTreeObserver!
Int
Int
Int
WindowId!
WindowInsetsController!
Int

This function is deprecated.

IBinder!
Int
Unit
Float
Float
Float
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
java-static View!
inflate(context: Context!, resource: Int, root: ViewGroup!)
Unit
invalidate(dirty: Rect!)

This function is deprecated.

Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
View!
keyboardNavigationClusterSearch(currentCluster: View!, direction: Int)
Unit
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
java-static IntArray<Int>!
mergeDrawableStates(baseState: IntArray!, additionalState: IntArray!)
Unit
Unit
Unit
Unit
WindowInsets!
Unit
Boolean
Boolean
Unit
Unit
InputConnection!
Unit
onCreateViewTranslationRequest(
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
onCreateVirtualViewTranslationRequests(
    virtualIds: LongArray!,
    supportedFormats: IntArray!,
    requestsCollector: Consumer<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
Unit
Boolean
Unit
Unit
Unit
onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect!
)
Boolean
Unit
Boolean
Unit
Unit
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)
Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent!)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent!)
Unit
onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
ContentInfo!
Unit
onScreenStateChanged(screenState: Int)
Unit
onScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
Boolean
onSetAlpha(alpha: Int)
Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
Unit
Boolean
Unit
Unit
Unit
Unit
onVisibilityChanged(changedView: View!, visibility: Int)
Unit
onWindowFocusChanged(hasWindowFocus: Boolean)
Unit

This function is deprecated.

Unit
Boolean
overScrollBy(
    deltaX: Int,
    deltaY: Int,
    scrollX: Int,
    scrollY: Int,
    scrollRangeX: Int,
    scrollRangeY: Int,
    maxOverScrollX: Int,
    maxOverScrollY: Int,
    isTouchEvent: Boolean
)
Boolean
performAccessibilityAction(action: Int, arguments: Bundle!)
Boolean
Boolean
Boolean
performHapticFeedback(feedbackConstant: Int)
Boolean
ContentInfo!
Unit
playSoundEffect(soundConstant: Int)
Boolean
post(action: Runnable!)
Boolean
postDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
postInvalidateDelayed(delayMilliseconds: Long)
Unit
Unit
Unit
postOnAnimationDelayed(action: Runnable!, delayMillis: Long)
Unit
Unit
Boolean
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Boolean
Unit
Boolean
Unit
T!
<T : View?> requireViewById(id: Int)
Unit
java-static Int
resolveSize(size: Int, measureSpec: Int)
java-static Int
resolveSizeAndState(size: Int, measureSpec: Int, childMeasuredState: Int)
Unit
Unit
saveAttributeDataForStyleable(
    context: Context!,
    styleable: IntArray!,
    attrs: AttributeSet!,
    t: TypedArray!,
    defStyleAttr: Int,
    defStyleRes: Int
)
Unit
Unit
scheduleDrawable(who: Drawable!, what: Runnable!, when: Long)
Unit
scrollBy(x: Int, y: Int)
Unit
scrollTo(x: Int, y: Int)
Unit
Unit
Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
Unit
Unit
Unit
Unit
setAccessibilityPaneTitle(accessibilityPaneTitle: CharSequence!)
Unit
Unit
Unit
setActivated(activated: Boolean)
Unit
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
Unit
Unit
Unit
setAlpha(alpha: Float)
Unit
setAnimation(animation: Animation!)
Unit
Unit
Unit
setAutofillHints(autofillHints: Array<String!>!)
Unit
Unit
setBackground(background: Drawable!)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setBottom(bottom: Int)
Unit
Unit
setClickable(clickable: Boolean)
Unit
setClipBounds(clipBounds: Rect!)
Unit
setClipToOutline(clipToOutline: Boolean)
Unit
Unit
setContentDescription(contentDescription: CharSequence!)
Unit
setContextClickable(contextClickable: Boolean)
Unit
setDefaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean)
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
setElevation(elevation: Float)
Unit
setEnabled(enabled: Boolean)
Unit
Unit
Unit
setFitsSystemWindows(fitSystemWindows: Boolean)
Unit
setFocusable(focusable: Boolean)
Unit
setFocusableInTouchMode(focusableInTouchMode: Boolean)
Unit
setFocusedByDefault(isFocusedByDefault: Boolean)
Unit
Unit
setForeground(foreground: Drawable!)
Unit
Unit
Unit
Unit
Unit
setHandwritingBoundsOffsets(
    offsetLeft: Float,
    offsetTop: Float,
    offsetRight: Float,
    offsetBottom: Float
)
Unit
Unit
setHapticFeedbackEnabled(hapticFeedbackEnabled: Boolean)
Unit
setHasTransientState(hasTransientState: Boolean)
Unit
setHorizontalFadingEdgeEnabled(horizontalFadingEdgeEnabled: Boolean)
Unit
setHorizontalScrollBarEnabled(horizontalScrollBarEnabled: Boolean)
Unit
Unit
Unit
setHovered(hovered: Boolean)
Unit
setId(id: Int)
Unit
Unit
Unit
Unit
setIsCredential(isCredential: Boolean)
Unit
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
Unit
setKeepScreenOn(keepScreenOn: Boolean)
Unit
Unit
Unit
Unit
setLayerType(layerType: Int, paint: Paint!)
Unit
setLayoutDirection(layoutDirection: Int)
Unit
Unit
setLeft(left: Int)
Unit
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Unit
setLongClickable(longClickable: Boolean)
Unit
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
Unit
setMinimumHeight(minHeight: Int)
Unit
setMinimumWidth(minWidth: Int)
Unit
Unit
setNextClusterForwardId(nextClusterForwardId: Int)
Unit
setNextFocusDownId(nextFocusDownId: Int)
Unit
setNextFocusForwardId(nextFocusForwardId: Int)
Unit
setNextFocusLeftId(nextFocusLeftId: Int)
Unit
setNextFocusRightId(nextFocusRightId: Int)
Unit
setNextFocusUpId(nextFocusUpId: Int)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
setOnReceiveContentListener(
    mimeTypes: Array<String!>!,
    listener: OnReceiveContentListener!
)
Unit
Unit

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
setOverScrollMode(overScrollMode: Int)
Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)
Unit
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Unit
setPivotX(pivotX: Float)
Unit
setPivotY(pivotY: Float)
Unit
setPointerIcon(pointerIcon: PointerIcon!)
Unit
setPreferKeepClear(preferKeepClear: Boolean)
Unit
Unit
setPressed(pressed: Boolean)
Unit
setRenderEffect(renderEffect: RenderEffect!)
Unit
setRevealOnFocusHint(revealOnFocus: Boolean)
Unit
setRight(right: Int)
Unit
setRotation(rotation: Float)
Unit
setRotationX(rotationX: Float)
Unit
setRotationY(rotationY: Float)
Unit
Unit
Unit
setScaleX(scaleX: Float)
Unit
setScaleY(scaleY: Float)
Unit
setScreenReaderFocusable(screenReaderFocusable: Boolean)
Unit
setScrollBarDefaultDelayBeforeFade(
    scrollBarDefaultDelayBeforeFade: Int
)
Unit
setScrollBarFadeDuration(scrollBarFadeDuration: Int)
Unit
setScrollBarSize(scrollBarSize: Int)
Unit
Unit
Unit
Unit
setScrollContainer(isScrollContainer: Boolean)
Unit
setScrollIndicators(indicators: Int)
Unit
setScrollX(value: Int)
Unit
setScrollY(value: Int)
Unit
Unit
setSelected(selected: Boolean)
Unit
setSoundEffectsEnabled(soundEffectsEnabled: Boolean)
Unit
setStateDescription(stateDescription: CharSequence!)
Unit
Unit
Unit

This function is deprecated.

Unit
setTag(tag: Any!)
Unit
setTextAlignment(textAlignment: Int)
Unit
setTextDirection(textDirection: Int)
Unit
Unit
setTop(top: Int)
Unit
Unit
Unit
setTransitionName(transitionName: String!)
Unit
Unit
setTranslationX(translationX: Float)
Unit
setTranslationY(translationY: Float)
Unit
setTranslationZ(translationZ: Float)
Unit
setVerticalFadingEdgeEnabled(verticalFadingEdgeEnabled: Boolean)
Unit
setVerticalScrollBarEnabled(verticalScrollBarEnabled: Boolean)
Unit
Unit
Unit
Unit
Unit
setVisibility(visibility: Int)
Unit
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)

This function is deprecated.

Unit
setWillNotDraw(willNotDraw: Boolean)
Unit
setX(x: Float)
Unit
setY(y: Float)
Unit
setZ(z: Float)
Boolean
ActionMode!
Unit
Boolean
startDrag(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)

This function is deprecated.

Boolean
startDragAndDrop(
    data: ClipData!,
    shadowBuilder: View.DragShadowBuilder!,
    myLocalState: Any!,
    flags: Int
)
Boolean
Unit
String!
Unit
Unit
Unit
Unit
Boolean
Boolean

This function is deprecated.

Boolean
From android.view.ViewGroup
Unit
Unit
addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo!,
    extraDataKey: String!,
    arguments: Bundle!
)
Unit
addKeyboardNavigationClusters(
    views: (Mutable)Collection<View!>!,
    direction: Int
)
Boolean
Unit
Unit
addView(child: View!)
Boolean
addViewInLayout(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
attachLayoutAnimationParameters(
    child: View!,
    params: ViewGroup.LayoutParams!,
    index: Int,
    count: Int
)
Unit
attachViewToParent(child: View!, index: Int, params: ViewGroup.LayoutParams!)
Unit
Boolean
Unit
Unit
childHasTransientStateChanged(
    child: View!,
    childHasTransientState: Boolean
)
Unit
Unit
Unit
Unit
Unit
debug(depth: Int)
Unit
Unit
Unit
detachViewsFromParent(start: Int, count: Int)
WindowInsets!
Boolean
Unit
Unit
dispatchCreateViewTranslationRequest(
    viewIds: (Mutable)Map<AutofillId!, LongArray!>!,
    supportedFormats: IntArray!,
    capability: TranslationCapability!,
    requests: (Mutable)List<ViewTranslationRequest!>!
)
Unit
Boolean
Unit
dispatchDraw(canvas: Canvas!)
Unit
Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
dispatchScrollCaptureSearch(
    localVisibleRect: Rect!,
    windowOffset: Point!,
    targets: Consumer<ScrollCaptureTarget!>!
)
Unit
Unit
Unit
Unit
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
dispatchUnhandledMove(focused: View!, direction: Int)
Unit
dispatchVisibilityChanged(changedView: View!, visibility: Int)
Unit
Unit
Unit
WindowInsets!
dispatchWindowInsetsAnimationProgress(
    insets: WindowInsets!,
    runningAnimations: (Mutable)List<WindowInsetsAnimation!>!
)
WindowInsetsAnimation.Bounds!
Unit

This function is deprecated.

Unit
Unit
Unit
View!
OnBackInvokedDispatcher!
Unit
findViewsWithText(
    outViews: ArrayList<View!>!,
    text: CharSequence!,
    flags: Int
)
View!
focusSearch(focused: View!, direction: Int)
Unit
Boolean
CharSequence!
View!
getChildAt(index: Int)
Int
Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)
java-static Int
getChildMeasureSpec(spec: Int, padding: Int, childDimension: Int)
Boolean
Boolean
getChildVisibleRect(child: View!, r: Rect!, offset: Point!)
Boolean
Boolean
Int
View!
LayoutAnimationController!
Animation.AnimationListener!
Int
LayoutTransition!
Int
ViewGroupOverlay!
Int

This function is deprecated.

Boolean
Boolean
Boolean
Int
indexOfChild(child: View!)
Unit
invalidateChild(child: View!, dirty: Rect!)

This function is deprecated.

ViewParent!
invalidateChildInParent(location: IntArray!, dirty: Rect!)

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean
Boolean

This function is deprecated.

Boolean
Boolean
Boolean
Unit
Unit
layout(l: Int, t: Int, r: Int, b: Int)
Unit
measureChild(
    child: View!,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
)
Unit
measureChildWithMargins(
    child: View!,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
)
Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
notifySubtreeAccessibilityStateChanged(
    child: View!,
    source: View!,
    changeType: Int
)
Unit
offsetDescendantRectToMyCoords(descendant: View!, rect: Rect!)
Unit
offsetRectIntoDescendantCoords(descendant: View!, rect: Rect!)
IntArray<Int>!
Unit
onDescendantInvalidated(child: View!, target: View!)
Boolean
Boolean
onNestedFling(
    target: View!,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)
Boolean
onNestedPreFling(target: View!, velocityX: Float, velocityY: Float)
Boolean
onNestedPrePerformAccessibilityAction(
    target: View!,
    action: Int,
    args: Bundle!
)
Unit
onNestedPreScroll(target: View!, dx: Int, dy: Int, consumed: IntArray!)
Unit
onNestedScroll(
    target: View!,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)
Unit
onNestedScrollAccepted(child: View!, target: View!, axes: Int)
Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect!)
Boolean
PointerIcon!
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)
Boolean
onStartNestedScroll(child: View!, target: View!, nestedScrollAxes: Int)
Unit
Unit
onViewAdded(child: View!)
Unit
Unit
Unit
Unit
Unit
removeDetachedView(child: View!, animate: Boolean)
Unit
removeView(view: View!)
Unit
removeViewAt(index: Int)
Unit
Unit
removeViews(start: Int, count: Int)
Unit
removeViewsInLayout(start: Int, count: Int)
Unit
requestChildFocus(child: View!, focused: View!)
Boolean
requestChildRectangleOnScreen(
    child: View!,
    rectangle: Rect!,
    immediate: Boolean
)
Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect!)
Boolean
Unit
Boolean
Unit
Unit
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit

This function is deprecated.

Unit
setClipChildren(clipChildren: Boolean)
Unit
setClipToPadding(clipToPadding: Boolean)
Unit
Unit
Unit
Unit
setLayoutMode(layoutMode: Int)
Unit
Unit
Unit
Unit
setPersistentDrawingCache(drawingCacheToKeep: Int)

This function is deprecated.

Unit
Unit
setTouchscreenBlocksFocus(touchscreenBlocksFocus: Boolean)
Unit
setTransitionGroup(isTransitionGroup: Boolean)
Unit
Boolean
Boolean
showContextMenuForChild(originalView: View!)
ActionMode!
startActionModeForChild(
    originalView: View!,
    callback: ActionMode.Callback!
)
Unit
Unit
Unit
Unit

Constants

LOCK_MODE_LOCKED_CLOSED

Added in 1.0.0
const val LOCK_MODE_LOCKED_CLOSED = 1: Int

The drawer is locked closed. The user may not open it, though the app may open it programmatically.

LOCK_MODE_LOCKED_OPEN

Added in 1.0.0
const val LOCK_MODE_LOCKED_OPEN = 2: Int

The drawer is locked open. The user may not close it, though the app may close it programmatically.

LOCK_MODE_UNDEFINED

Added in 1.0.0
const val LOCK_MODE_UNDEFINED = 3: Int

The drawer's lock state is reset to default.

LOCK_MODE_UNLOCKED

Added in 1.0.0
const val LOCK_MODE_UNLOCKED = 0: Int

The drawer is unlocked.

STATE_DRAGGING

Added in 1.0.0
const val STATE_DRAGGING = 1: Int

Indicates that a drawer is currently being dragged by the user.

STATE_IDLE

Added in 1.0.0
const val STATE_IDLE = 0: Int

Indicates that any drawers are in an idle, settled state. No animation is in progress.

STATE_SETTLING

Added in 1.0.0
const val STATE_SETTLING = 2: Int

Indicates that a drawer is in the process of settling to a final position.

Public constructors

DrawerLayout

Added in 1.0.0
DrawerLayout(context: Context)

DrawerLayout

Added in 1.0.0
DrawerLayout(context: Context, attrs: AttributeSet?)

DrawerLayout

Added in 1.0.0
DrawerLayout(context: Context, attrs: AttributeSet?, defStyleAttr: Int)

Public functions

addDrawerListener

Added in 1.0.0
fun addDrawerListener(listener: DrawerLayout.DrawerListener): Unit

Adds the specified listener to the list of listeners that will be notified of drawer events.

Parameters
listener: DrawerLayout.DrawerListener

Listener to notify when drawer events occur.

addFocusables

fun addFocusables(views: ArrayList<View!>!, direction: Int, focusableMode: Int): Unit

addView

fun addView(child: View!, index: Int, params: ViewGroup.LayoutParams!): Unit

close

Added in 1.1.0
fun close(): Unit

Close the START drawer by animating it out of view.

closeDrawer

Added in 1.0.0
fun closeDrawer(drawerView: View): Unit

Close the specified drawer view by animating it into view.

Parameters
drawerView: View

Drawer view to close

closeDrawer

Added in 1.0.0
fun closeDrawer(@DrawerLayout.EdgeGravity gravity: Int): Unit

Close the specified drawer by animating it out of view.

Parameters
@DrawerLayout.EdgeGravity gravity: Int

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

closeDrawer

Added in 1.0.0
fun closeDrawer(drawerView: View, animate: Boolean): Unit

Close the specified drawer view.

Parameters
drawerView: View

Drawer view to close

animate: Boolean

Whether closing of the drawer should be animated.

closeDrawer

Added in 1.0.0
fun closeDrawer(@DrawerLayout.EdgeGravity gravity: Int, animate: Boolean): Unit

Close the specified drawer.

Parameters
@DrawerLayout.EdgeGravity gravity: Int

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

animate: Boolean

Whether closing of the drawer should be animated.

closeDrawers

Added in 1.0.0
fun closeDrawers(): Unit

Close all currently open drawer views by animating them out of view.

computeScroll

fun computeScroll(): Unit

dispatchGenericMotionEvent

fun dispatchGenericMotionEvent(event: MotionEvent!): Boolean

generateLayoutParams

fun generateLayoutParams(attrs: AttributeSet!): ViewGroup.LayoutParams!

getDrawerElevation

Added in 1.0.0
fun getDrawerElevation(): Float

The base elevation of the drawer(s) relative to the parent, in pixels. Note that the elevation change is only supported in API 21 and above. For unsupported API levels, 0 will be returned as the elevation.

Returns
Float

The base depth position of the view, in pixels.

getDrawerLockMode

Added in 1.0.0
@DrawerLayout.LockMode
fun getDrawerLockMode(drawerView: View): Int

Check the lock mode of the given drawer view.

Parameters
drawerView: View

Drawer view to check lock mode

getDrawerLockMode

Added in 1.0.0
@DrawerLayout.LockMode
fun getDrawerLockMode(@DrawerLayout.EdgeGravity edgeGravity: Int): Int

Check the lock mode of the drawer with the given gravity.

Parameters
@DrawerLayout.EdgeGravity edgeGravity: Int

Gravity of the drawer to check

getDrawerTitle

Added in 1.0.0
fun getDrawerTitle(@DrawerLayout.EdgeGravity edgeGravity: Int): CharSequence?

Returns the title of the drawer with the given gravity.

Parameters
@DrawerLayout.EdgeGravity edgeGravity: Int

Gravity.LEFT, RIGHT, START or END. Expresses which drawer to return the title for.

Returns
CharSequence?

The title of the drawer, or null if none set.

See also
setDrawerTitle

getStatusBarBackgroundDrawable

Added in 1.0.0
fun getStatusBarBackgroundDrawable(): Drawable?

Gets the drawable used to draw in the insets area for the status bar.

Returns
Drawable?

The status bar background drawable, or null if none set

isDrawerOpen

Added in 1.0.0
fun isDrawerOpen(@DrawerLayout.EdgeGravity drawerGravity: Int): Boolean

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
@DrawerLayout.EdgeGravity drawerGravity: Int

Gravity of the drawer to check

Returns
Boolean

true if the given drawer view is in an open state

isDrawerOpen

Added in 1.0.0
fun isDrawerOpen(drawer: View): Boolean

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.

Parameters
drawer: View

Drawer view to check

Returns
Boolean

true if the given drawer view is in an open state

See also
isDrawerVisible

isDrawerVisible

Added in 1.0.0
fun isDrawerVisible(@DrawerLayout.EdgeGravity drawerGravity: Int): Boolean

Check if a given drawer view is currently visible on-screen. The drawer may be only peeking onto the screen, fully extended, or anywhere in between. If there is no drawer with the given gravity this method will return false.

Parameters
@DrawerLayout.EdgeGravity drawerGravity: Int

Gravity of the drawer to check

Returns
Boolean

true if the given drawer is visible on-screen

isDrawerVisible

Added in 1.0.0
fun isDrawerVisible(drawer: View): Boolean

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: View

Drawer view to check

Returns
Boolean

true if the given drawer is visible on-screen

See also
isDrawerOpen

isOpen

Added in 1.1.0
fun isOpen(): Boolean

Check if the START drawer 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.

Returns
Boolean

true if the START drawer is in an open state

onDraw

Added in 1.0.0
fun onDraw(c: Canvas): Unit

onInterceptTouchEvent

fun onInterceptTouchEvent(ev: MotionEvent!): Boolean

onKeyDown

fun onKeyDown(keyCode: Int, event: KeyEvent!): Boolean

onKeyUp

fun onKeyUp(keyCode: Int, event: KeyEvent!): Boolean

onRtlPropertiesChanged

fun onRtlPropertiesChanged(layoutDirection: Int): Unit

onTouchEvent

fun onTouchEvent(ev: MotionEvent!): Boolean

open

Added in 1.1.0
fun open(): Unit

Open the START drawer by animating it into view.

openDrawer

Added in 1.0.0
fun openDrawer(drawerView: View): Unit

Open the specified drawer view by animating it into view.

Parameters
drawerView: View

Drawer view to open

openDrawer

Added in 1.0.0
fun openDrawer(@DrawerLayout.EdgeGravity gravity: Int): Unit

Open the specified drawer by animating it out of view.

Parameters
@DrawerLayout.EdgeGravity gravity: Int

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

openDrawer

Added in 1.0.0
fun openDrawer(drawerView: View, animate: Boolean): Unit

Open the specified drawer view.

Parameters
drawerView: View

Drawer view to open

animate: Boolean

Whether opening of the drawer should be animated.

openDrawer

Added in 1.0.0
fun openDrawer(@DrawerLayout.EdgeGravity gravity: Int, animate: Boolean): Unit

Open the specified drawer.

Parameters
@DrawerLayout.EdgeGravity gravity: Int

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

animate: Boolean

Whether opening of the drawer should be animated.

removeDrawerListener

Added in 1.0.0
fun removeDrawerListener(listener: DrawerLayout.DrawerListener): Unit

Removes the specified listener from the list of listeners that will be notified of drawer events.

Parameters
listener: DrawerLayout.DrawerListener

Listener to remove from being notified of drawer events

requestDisallowInterceptTouchEvent

fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean): Unit

requestLayout

fun requestLayout(): Unit

setDrawerElevation

Added in 1.0.0
fun setDrawerElevation(elevation: Float): Unit

Sets the base elevation of the drawer(s) relative to the parent, in pixels. Note that the elevation change is only supported in API 21 and above.

Parameters
elevation: Float

The base depth position of the view, in pixels.

setDrawerListener

Added in 1.0.0
Deprecated in 1.0.0
fun setDrawerListener(listener: DrawerLayout.DrawerListener!): Unit

Set a listener to be notified of drawer events. Note that this method is deprecated and you should use addDrawerListener to add a listener and removeDrawerListener to remove a registered listener.

Parameters
listener: DrawerLayout.DrawerListener!

Listener to notify when drawer events occur

setDrawerLockMode

Added in 1.0.0
fun setDrawerLockMode(@DrawerLayout.LockMode lockMode: Int): Unit

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, closeDrawer and friends if a drawer is locked.

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

Parameters
@DrawerLayout.LockMode lockMode: Int

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

setDrawerLockMode

Added in 1.0.0
fun setDrawerLockMode(@DrawerLayout.LockMode lockMode: Int, drawerView: View): Unit

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, closeDrawer and friends if a drawer is locked.

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

Parameters
@DrawerLayout.LockMode lockMode: Int

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

drawerView: View

The drawer view to change the lock mode for

setDrawerLockMode

Added in 1.0.0
fun setDrawerLockMode(
    @DrawerLayout.LockMode lockMode: Int,
    @DrawerLayout.EdgeGravity edgeGravity: Int
): Unit

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, closeDrawer and friends if a drawer is locked.

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

Parameters
@DrawerLayout.LockMode lockMode: Int

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

@DrawerLayout.EdgeGravity edgeGravity: Int

Gravity.LEFT, RIGHT, START or END. Expresses which drawer to change the mode for.

setDrawerShadow

Added in 1.0.0
fun setDrawerShadow(
    resId: @DrawableRes Int,
    @DrawerLayout.EdgeGravity gravity: Int
): Unit

Set a simple drawable used for the left or right shadow. The drawable provided must have a nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer instead of using the provided shadow drawable.

Note that for better support for both left-to-right and right-to-left layout directions, a drawable for RTL layout (in additional to the one in LTR layout) can be defined with a resource qualifier "ldrtl" for API 17 and above with the gravity START. Alternatively, for API 23 and above, the drawable can auto-mirrored such that the drawable will be mirrored in RTL layout.

Parameters
resId: @DrawableRes Int

Resource id of a shadow drawable to use at the edge of a drawer

@DrawerLayout.EdgeGravity gravity: Int

Which drawer the shadow should apply to

setDrawerShadow

Added in 1.0.0
fun setDrawerShadow(
    shadowDrawable: Drawable?,
    @DrawerLayout.EdgeGravity gravity: Int
): Unit

Set a simple drawable used for the left or right shadow. The drawable provided must have a nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer instead of using the provided shadow drawable.

Note that for better support for both left-to-right and right-to-left layout directions, a drawable for RTL layout (in additional to the one in LTR layout) can be defined with a resource qualifier "ldrtl" for API 17 and above with the gravity START. Alternatively, for API 23 and above, the drawable can auto-mirrored such that the drawable will be mirrored in RTL layout.

Parameters
shadowDrawable: Drawable?

Shadow drawable to use at the edge of a drawer

@DrawerLayout.EdgeGravity gravity: Int

Which drawer the shadow should apply to

setDrawerTitle

Added in 1.0.0
fun setDrawerTitle(
    @DrawerLayout.EdgeGravity edgeGravity: Int,
    title: CharSequence?
): Unit

Sets the title of the drawer with the given gravity.

When accessibility is turned on, this is the title that will be used to identify the drawer to the active accessibility service.

Parameters
@DrawerLayout.EdgeGravity edgeGravity: Int

Gravity.LEFT, RIGHT, START or END. Expresses which drawer to set the title for.

title: CharSequence?

The title for the drawer.

setScrimColor

Added in 1.0.0
fun setScrimColor(color: @ColorInt Int): Unit

Set a color to use for the scrim that obscures primary content while a drawer is open.

Parameters
color: @ColorInt Int

Color to use in 0xAARRGGBB format.

setStatusBarBackground

Added in 1.0.0
fun setStatusBarBackground(bg: Drawable?): Unit

Set a drawable to draw in the insets area for the status bar. Note that this will only be activated if this DrawerLayout fitsSystemWindows.

Parameters
bg: Drawable?

Background drawable to draw behind the status bar

setStatusBarBackground

Added in 1.0.0
fun setStatusBarBackground(resId: Int): Unit

Set a drawable to draw in the insets area for the status bar. Note that this will only be activated if this DrawerLayout fitsSystemWindows.

Parameters
resId: Int

Resource id of a background drawable to draw behind the status bar

setStatusBarBackgroundColor

Added in 1.0.0
fun setStatusBarBackgroundColor(color: @ColorInt Int): Unit

Set a drawable to draw in the insets area for the status bar. Note that this will only be activated if this DrawerLayout fitsSystemWindows.

Parameters
color: @ColorInt Int

Color to use as a background drawable to draw behind the status bar in 0xAARRGGBB format.

Protected functions

checkLayoutParams

protected fun checkLayoutParams(p: ViewGroup.LayoutParams!): Boolean

drawChild

protected fun drawChild(canvas: Canvas, child: View!, drawingTime: Long): Boolean

generateDefaultLayoutParams

protected fun generateDefaultLayoutParams(): ViewGroup.LayoutParams!

generateLayoutParams

protected fun generateLayoutParams(p: ViewGroup.LayoutParams!): ViewGroup.LayoutParams!

onAttachedToWindow

protected fun onAttachedToWindow(): Unit

onDetachedFromWindow

protected fun onDetachedFromWindow(): Unit

onLayout

protected fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int): Unit

onMeasure

protected fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit

onRestoreInstanceState

protected fun onRestoreInstanceState(state: Parcelable!): Unit

onSaveInstanceState

protected fun onSaveInstanceState(): Parcelable