public class DrawerLayout
extends android.view.ViewGroup
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.
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.
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.
限定符和类型 | 类和说明 |
---|---|
static interface |
DrawerLayout.DrawerListener
Listener for monitoring events about drawers.
|
static class |
DrawerLayout.LayoutParams |
static interface |
DrawerLayout.OnShouldeSlideListener |
protected static class |
DrawerLayout.SavedState
State persisted across instances
|
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnCapturedPointerListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, 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.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener, android.view.View.OnUnhandledKeyEventListener
限定符和类型 | 字段和说明 |
---|---|
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_UNDEFINED
The drawer's lock state is reset to default.
|
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.
|
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, 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, FOCUSABLE, FOCUSABLE_AUTO, 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_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, IMPORTANT_FOR_CONTENT_CAPTURE_NO, IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_YES, IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, 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, NOT_FOCUSABLE, 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_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, 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_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, 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_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
构造器和说明 |
---|
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) |
限定符和类型 | 方法和说明 |
---|---|
void |
addDrawerListener(DrawerLayout.DrawerListener listener)
Adds the specified listener to the list of listeners that will be notified of drawer events.
|
void |
addFocusables(java.util.ArrayList<android.view.View> views,
int direction,
int focusableMode) |
void |
addView(android.view.View child,
int index,
android.view.ViewGroup.LayoutParams params) |
protected boolean |
checkLayoutParams(android.view.ViewGroup.LayoutParams p) |
void |
closeDrawer(int gravity)
Close the specified drawer by animating it out of view.
|
void |
closeDrawer(int gravity,
boolean animate)
Close the specified drawer.
|
void |
closeDrawer(android.view.View drawerView)
Close the specified drawer view by animating it into view.
|
void |
closeDrawer(android.view.View drawerView,
boolean animate)
Close the specified drawer view.
|
void |
closeDrawers()
Close all currently open drawer views by animating them out of view.
|
void |
computeScroll() |
boolean |
dispatchGenericMotionEvent(android.view.MotionEvent event) |
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) |
float |
getDrawerElevation()
The base elevation of the drawer(s) relative to the parent, in pixels.
|
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.
|
java.lang.CharSequence |
getDrawerTitle(int edgeGravity)
Returns the title of the drawer with the given gravity.
|
android.graphics.drawable.Drawable |
getStatusBarBackgroundDrawable()
Gets the drawable used to draw in the insets area for the status bar.
|
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() |
void |
onDraw(android.graphics.Canvas c) |
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) |
void |
onRtlPropertiesChanged(int layoutDirection) |
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(int gravity,
boolean animate)
Open the specified drawer.
|
void |
openDrawer(android.view.View drawerView)
Open the specified drawer view by animating it into view.
|
void |
openDrawer(android.view.View drawerView,
boolean animate)
Open the specified drawer view.
|
void |
removeDrawerListener(DrawerLayout.DrawerListener listener)
Removes the specified listener from the list of listeners that will be notified of drawer
events.
|
void |
requestDisallowInterceptTouchEvent(boolean disallowIntercept) |
void |
requestLayout() |
void |
setChildInsets(java.lang.Object insets,
boolean draw) |
void |
setDrawerElevation(float elevation)
Sets the base elevation of the drawer(s) relative to the parent, in pixels.
|
void |
setDrawerListener(DrawerLayout.DrawerListener listener)
已过时。
|
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 |
setDrawerTitle(int edgeGravity,
java.lang.CharSequence title)
Sets the title of the drawer with the given gravity.
|
void |
setEdgeSize(androidx.customview.widget.ViewDragHelper helper,
float displayWidthPercentage) |
void |
setScrimColor(int color)
Set a color to use for the scrim that obscures primary content while a drawer is open.
|
void |
setShouldeSlideListener(DrawerLayout.OnShouldeSlideListener listener) |
void |
setStatusBarBackground(android.graphics.drawable.Drawable bg)
Set a drawable to draw in the insets area for the status bar.
|
void |
setStatusBarBackground(int resId)
Set a drawable to draw in the insets area for the status bar.
|
void |
setStatusBarBackgroundColor(int color)
Set a drawable to draw in the insets area for the status bar.
|
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, endViewTransition, findFocus, findViewsWithText, focusableViewAvailable, focusSearch, gatherTransparentRegion, getAccessibilityClassName, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onCreateDrawableState, onDescendantInvalidated, onInterceptHoverEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, setWindowInsetsAnimationCallback, shouldDelayChildPressedState, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, autofill, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestFitSystemWindows
public static final int STATE_IDLE
public static final int STATE_DRAGGING
public static final int STATE_SETTLING
public static final int LOCK_MODE_UNLOCKED
public static final int LOCK_MODE_LOCKED_CLOSED
public static final int LOCK_MODE_LOCKED_OPEN
public static final int LOCK_MODE_UNDEFINED
public DrawerLayout(@NonNull android.content.Context context)
public DrawerLayout(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
public DrawerLayout(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs, int defStyle)
public void setDrawerElevation(float elevation)
elevation
- The base depth position of the view, in pixels.public float getDrawerElevation()
public void setChildInsets(java.lang.Object insets, boolean draw)
public void setDrawerShadow(android.graphics.drawable.Drawable shadowDrawable, int gravity)
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
GravityCompat.START
. Alternatively, for API 23 and above, the drawable can
auto-mirrored such that the drawable will be mirrored in RTL layout.
shadowDrawable
- Shadow drawable to use at the edge of a drawergravity
- Which drawer the shadow should apply topublic void setDrawerShadow(@DrawableRes int resId, int gravity)
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
GravityCompat.START
. Alternatively, for API 23 and above, the drawable can
auto-mirrored such that the drawable will be mirrored in RTL layout.
resId
- Resource id of a shadow drawable to use at the edge of a drawergravity
- Which drawer the shadow should apply topublic void setScrimColor(int color)
color
- Color to use in 0xAARRGGBB format.public void setShouldeSlideListener(DrawerLayout.OnShouldeSlideListener listener)
@Deprecated public void setDrawerListener(DrawerLayout.DrawerListener listener)
addDrawerListener(DrawerListener)
addDrawerListener(DrawerListener)
to add a listener and
removeDrawerListener(DrawerListener)
to remove a registered listener.listener
- Listener to notify when drawer events occurDrawerLayout.DrawerListener
,
addDrawerListener(DrawerListener)
,
removeDrawerListener(DrawerListener)
public void addDrawerListener(@NonNull DrawerLayout.DrawerListener listener)
listener
- Listener to notify when drawer events occur.removeDrawerListener(DrawerListener)
public void removeDrawerListener(@NonNull DrawerLayout.DrawerListener listener)
listener
- Listener to remove from being notified of drawer eventsaddDrawerListener(DrawerListener)
public void setDrawerLockMode(int lockMode)
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.
lockMode
- The new lock mode for the given drawer. One of LOCK_MODE_UNLOCKED
,
LOCK_MODE_LOCKED_CLOSED
or LOCK_MODE_LOCKED_OPEN
.public void setDrawerLockMode(int lockMode, int edgeGravity)
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.
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.LOCK_MODE_UNLOCKED
,
LOCK_MODE_LOCKED_CLOSED
,
LOCK_MODE_LOCKED_OPEN
public void setDrawerLockMode(int lockMode, @NonNull android.view.View drawerView)
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.
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 forLOCK_MODE_UNLOCKED
,
LOCK_MODE_LOCKED_CLOSED
,
LOCK_MODE_LOCKED_OPEN
public int getDrawerLockMode(int edgeGravity)
edgeGravity
- Gravity of the drawer to checkLOCK_MODE_UNLOCKED
, LOCK_MODE_LOCKED_CLOSED
or
LOCK_MODE_LOCKED_OPEN
.public int getDrawerLockMode(@NonNull android.view.View drawerView)
drawerView
- Drawer view to check lock modeLOCK_MODE_UNLOCKED
, LOCK_MODE_LOCKED_CLOSED
or
LOCK_MODE_LOCKED_OPEN
.public void setDrawerTitle(int edgeGravity, @Nullable java.lang.CharSequence title)
When accessibility is turned on, this is the title that will be used to identify the drawer to the active accessibility service.
edgeGravity
- Gravity.LEFT, RIGHT, START or END. Expresses which
drawer to set the title for.title
- The title for the drawer.@Nullable public java.lang.CharSequence getDrawerTitle(int edgeGravity)
edgeGravity
- Gravity.LEFT, RIGHT, START or END. Expresses which
drawer to return the title for.setDrawerTitle(int, CharSequence)
protected void onDetachedFromWindow()
onDetachedFromWindow
在类中 android.view.ViewGroup
protected void onAttachedToWindow()
onAttachedToWindow
在类中 android.view.ViewGroup
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
onMeasure
在类中 android.view.View
protected void onLayout(boolean changed, int l, int t, int r, int b)
onLayout
在类中 android.view.ViewGroup
public void requestLayout()
requestLayout
在接口中 android.view.ViewParent
requestLayout
在类中 android.view.View
public void computeScroll()
computeScroll
在类中 android.view.View
public void setStatusBarBackground(@Nullable android.graphics.drawable.Drawable bg)
bg
- Background drawable to draw behind the status bar@Nullable public android.graphics.drawable.Drawable getStatusBarBackgroundDrawable()
public void setStatusBarBackground(int resId)
resId
- Resource id of a background drawable to draw behind the status barpublic void setStatusBarBackgroundColor(int color)
color
- Color to use as a background drawable to draw behind the status bar
in 0xAARRGGBB format.public void onRtlPropertiesChanged(int layoutDirection)
onRtlPropertiesChanged
在类中 android.view.View
public void onDraw(android.graphics.Canvas c)
onDraw
在类中 android.view.View
protected boolean drawChild(android.graphics.Canvas canvas, android.view.View child, long drawingTime)
drawChild
在类中 android.view.ViewGroup
public boolean onInterceptTouchEvent(android.view.MotionEvent ev)
onInterceptTouchEvent
在类中 android.view.ViewGroup
public boolean dispatchGenericMotionEvent(android.view.MotionEvent event)
dispatchGenericMotionEvent
在类中 android.view.View
public boolean onTouchEvent(android.view.MotionEvent ev)
onTouchEvent
在类中 android.view.View
public void setEdgeSize(androidx.customview.widget.ViewDragHelper helper, float displayWidthPercentage)
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
requestDisallowInterceptTouchEvent
在接口中 android.view.ViewParent
requestDisallowInterceptTouchEvent
在类中 android.view.ViewGroup
public void closeDrawers()
public void openDrawer(@NonNull android.view.View drawerView)
drawerView
- Drawer view to openpublic void openDrawer(@NonNull android.view.View drawerView, boolean animate)
drawerView
- Drawer view to openanimate
- Whether opening of the drawer should be animated.public void openDrawer(int gravity)
gravity
- Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right.
GravityCompat.START or GravityCompat.END may also be used.public void openDrawer(int gravity, boolean animate)
gravity
- Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right.
GravityCompat.START or GravityCompat.END may also be used.animate
- Whether opening of the drawer should be animated.public void closeDrawer(@NonNull android.view.View drawerView)
drawerView
- Drawer view to closepublic void closeDrawer(@NonNull android.view.View drawerView, boolean animate)
drawerView
- Drawer view to closeanimate
- Whether closing of the drawer should be animated.public void closeDrawer(int gravity)
gravity
- Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right.
GravityCompat.START or GravityCompat.END may also be used.public void closeDrawer(int gravity, boolean animate)
gravity
- Gravity.LEFT to move the left drawer or Gravity.RIGHT for the right.
GravityCompat.START or GravityCompat.END may also be used.animate
- Whether closing of the drawer should be animated.public boolean isDrawerOpen(@NonNull android.view.View drawer)
isDrawerVisible(android.view.View)
.drawer
- Drawer view to checkisDrawerVisible(android.view.View)
public boolean isDrawerOpen(int drawerGravity)
drawerGravity
- Gravity of the drawer to checkpublic boolean isDrawerVisible(@NonNull android.view.View drawer)
drawer
- Drawer view to checkisDrawerOpen(android.view.View)
public boolean isDrawerVisible(int drawerGravity)
drawerGravity
- Gravity of the drawer to checkprotected android.view.ViewGroup.LayoutParams generateDefaultLayoutParams()
generateDefaultLayoutParams
在类中 android.view.ViewGroup
protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p)
generateLayoutParams
在类中 android.view.ViewGroup
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
checkLayoutParams
在类中 android.view.ViewGroup
public android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
generateLayoutParams
在类中 android.view.ViewGroup
public void addFocusables(java.util.ArrayList<android.view.View> views, int direction, int focusableMode)
addFocusables
在类中 android.view.ViewGroup
public boolean onKeyDown(int keyCode, android.view.KeyEvent event)
onKeyDown
在接口中 android.view.KeyEvent.Callback
onKeyDown
在类中 android.view.View
public boolean onKeyUp(int keyCode, android.view.KeyEvent event)
onKeyUp
在接口中 android.view.KeyEvent.Callback
onKeyUp
在类中 android.view.View
protected void onRestoreInstanceState(android.os.Parcelable state)
onRestoreInstanceState
在类中 android.view.View
protected android.os.Parcelable onSaveInstanceState()
onSaveInstanceState
在类中 android.view.View
public void addView(android.view.View child, int index, android.view.ViewGroup.LayoutParams params)
addView
在类中 android.view.ViewGroup