-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.ViewManager,android.view.ViewParent,android.view.accessibility.AccessibilityEventSource,tds.androidx.core.view.NestedScrollingParent,tds.androidx.core.view.NestedScrollingParent2,tds.androidx.core.view.NestedScrollingParent3
public class CoordinatorLayout extends ViewGroup implements NestedScrollingParent2, NestedScrollingParent3
CoordinatorLayout is a super-powered FrameLayout.
CoordinatorLayout is intended for two primary use cases:
- As a top-level application decor or chrome layout
- As a container for a specific interaction with one or more child views
By specifying Behaviors for child views of a CoordinatorLayout you can provide many different interactions within a single parent and those views can also interact with one another. View classes can specify a default behavior when used as a child of a CoordinatorLayout by implementing the AttachedBehavior interface.
Behaviors may be used to implement a variety of interactions and additional layout modifications ranging from sliding drawers and panels to swipe-dismissable elements and buttons that stick to other elements as they move and animate.
Children of a CoordinatorLayout may have an anchor. This view id must correspond to an arbitrary descendant of the CoordinatorLayout, but it may not be the anchored child itself or a descendant of the anchored child. This can be used to place floating views relative to other arbitrary content panes.
Children can specify insetEdge to describe how the view insets the CoordinatorLayout. Any child views which are set to dodge the same inset edges by dodgeInsetEdges will be moved appropriately so that the views do not overlap.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceCoordinatorLayout.DispatchChangeEventpublic @interfaceCoordinatorLayout.DefaultBehaviorDefines the default Behavior of a View class.
When writing a custom view, use this annotation to define the default behaviorwhen used as a direct child of an CoordinatorLayout. The default behavior can beoverridden using setBehavior.
Example:
@DefaultBehavior(MyBehavior.class)public interfaceCoordinatorLayout.AttachedBehaviorDefines the default attached Behavior of a View class
When writing a custom view, implement this interface to return the default behaviorwhen used as a direct child of an CoordinatorLayout. The default behavior can beoverridden using setBehavior.
public abstract classCoordinatorLayout.BehaviorInteraction behavior plugin for child views of CoordinatorLayout.
A Behavior implements one or more interactions that a user can take on a child view.These interactions may include drags, swipes, flings, or any other gestures.
public classCoordinatorLayout.LayoutParamsParameters describing the desired layout for a child of a CoordinatorLayout.
-
Constructor Summary
Constructors Constructor Description CoordinatorLayout(Context context)CoordinatorLayout(Context context, AttributeSet attrs)CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr)
-
Method Summary
Modifier and Type Method Description voidsetOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener)voidonAttachedToWindow()voidonDetachedFromWindow()voidsetStatusBarBackground(@Nullable() Drawable bg)Set a drawable to draw in the insets area for the status bar. DrawablegetStatusBarBackground()Gets the drawable used to draw in the insets area for the status bar. voidsetVisibility(int visibility)voidsetStatusBarBackgroundResource(@DrawableRes() int resId)Set a drawable to draw in the insets area for the status bar. voidsetStatusBarBackgroundColor(@ColorInt() int color)Set a drawable to draw in the insets area for the status bar. final WindowInsetsCompatgetLastWindowInsets()booleanonInterceptTouchEvent(MotionEvent ev)booleanonTouchEvent(MotionEvent ev)voidrequestDisallowInterceptTouchEvent(boolean disallowIntercept)voidonMeasureChild(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)Called to measure each individual child view unless a Behavior is present. voidonLayoutChild(@NonNull() View child, int layoutDirection)Called to lay out each individual child view unless a Behavior is present. voidonDraw(Canvas c)voidsetFitsSystemWindows(boolean fitSystemWindows)voiddispatchDependentViewsChanged(@NonNull() View view)Allows the caller to manually dispatch onDependentViewChanged to the associated Behavior instances of views which depend on the provided View. List<View>getDependencies(@NonNull() View child)Returns the list of views which the provided view depends on. List<View>getDependents(@NonNull() View child)Returns the list of views which depend on the provided view. booleanisPointInChildBounds(@NonNull() View child, int x, int y)Check if a given point in the CoordinatorLayout's coordinates are within the view bounds of thegiven direct child view. booleandoViewsOverlap(@NonNull() View first, @NonNull() View second)Check whether two views overlap each other. CoordinatorLayout.LayoutParamsgenerateLayoutParams(AttributeSet attrs)booleanonStartNestedScroll(View child, View target, int nestedScrollAxes)booleanonStartNestedScroll(View child, View target, int axes, int type)React to a descendant view initiating a nestable scroll operation, claiming thenested scroll operation if appropriate. voidonNestedScrollAccepted(View child, View target, int nestedScrollAxes)voidonNestedScrollAccepted(View child, View target, int nestedScrollAxes, int type)React to the successful claiming of a nested scroll operation. voidonStopNestedScroll(View target)voidonStopNestedScroll(View target, int type)React to a nested scroll operation ending. voidonNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)voidonNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type)React to a nested scroll in progress. voidonNestedScroll(@NonNull() View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @NonNull() Array<int> consumed)React to a nested scroll in progress. voidonNestedPreScroll(View target, int dx, int dy, Array<int> consumed)voidonNestedPreScroll(View target, int dx, int dy, Array<int> consumed, int type)React to a nested scroll in progress before the target view consumes a portion of the scroll. booleanonNestedFling(View target, float velocityX, float velocityY, boolean consumed)booleanonNestedPreFling(View target, float velocityX, float velocityY)intgetNestedScrollAxes()booleanrequestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)-
Methods inherited from class android.view.ViewGroup
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchSetActivated, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, endViewTransition, findFocus, findViewsWithText, focusSearch, focusableViewAvailable, gatherTransparentRegion, generateLayoutParams, getAccessibilityClassName, getChildAt, getChildCount, getChildMeasureSpec, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onDescendantInvalidated, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setTouchscreenBlocksFocus, setTransitionGroup, setWindowInsetsAnimationCallback, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout -
Methods inherited from class android.view.View
addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, bringToFront, buildDrawingCache, buildLayer, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeScroll, computeSystemWindowInsets, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, 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, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getOverlay, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTouchDelegate, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, 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, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, offsetLeftAndRight, offsetTopAndBottom, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onCreateInputConnection, onDragEvent, onDrawForeground, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onRtlPropertiesChanged, onScreenStateChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, 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, 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, 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, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollX, setScrollY, setScrollbarFadingEnabled, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw -
Methods inherited from class tds.androidx.core.view.NestedScrollingParent2
onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onStartNestedScroll, onStopNestedScroll -
Methods inherited from class tds.androidx.core.view.NestedScrollingParent
onNestedFling, onNestedPreFling, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onStartNestedScroll, onStopNestedScroll -
Methods inherited from class tds.androidx.core.view.NestedScrollingParent3
onNestedScroll -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
CoordinatorLayout
CoordinatorLayout(Context context)
-
CoordinatorLayout
CoordinatorLayout(Context context, AttributeSet attrs)
-
CoordinatorLayout
CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr)
-
-
Method Detail
-
setOnHierarchyChangeListener
void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener)
-
onAttachedToWindow
void onAttachedToWindow()
-
onDetachedFromWindow
void onDetachedFromWindow()
-
setStatusBarBackground
void setStatusBarBackground(@Nullable() Drawable bg)
Set a drawable to draw in the insets area for the status bar. Note that this will only beactivated if this DrawerLayout fitsSystemWindows.
- Parameters:
bg- Background drawable to draw behind the status bar
-
getStatusBarBackground
@Nullable() Drawable getStatusBarBackground()
Gets the drawable used to draw in the insets area for the status bar.
-
setVisibility
void setVisibility(int visibility)
-
setStatusBarBackgroundResource
void setStatusBarBackgroundResource(@DrawableRes() int resId)
Set a drawable to draw in the insets area for the status bar. Note that this will only beactivated if this DrawerLayout fitsSystemWindows.
- Parameters:
resId- Resource id of a background drawable to draw behind the status bar
-
setStatusBarBackgroundColor
void setStatusBarBackgroundColor(@ColorInt() int color)
Set a drawable to draw in the insets area for the status bar. Note that this will only beactivated if this DrawerLayout fitsSystemWindows.
- Parameters:
color- Color to use as a background drawable to draw behind the status bar in 0xAARRGGBBformat.
-
getLastWindowInsets
final WindowInsetsCompat getLastWindowInsets()
-
onInterceptTouchEvent
boolean onInterceptTouchEvent(MotionEvent ev)
-
onTouchEvent
boolean onTouchEvent(MotionEvent ev)
-
requestDisallowInterceptTouchEvent
void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
-
onMeasureChild
void onMeasureChild(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
Called to measure each individual child view unless a Behavior is present. TheBehavior may choose to delegate child measurement to this method.
- Parameters:
child- the child to measureparentWidthMeasureSpec- the width requirements for this viewwidthUsed- extra space that has been used up by the parent horizontally (possibly byother children of the parent)parentHeightMeasureSpec- the height requirements for this viewheightUsed- extra space that has been used up by the parent vertically (possibly by otherchildren of the parent)
-
onLayoutChild
void onLayoutChild(@NonNull() View child, int layoutDirection)
Called to lay out each individual child view unless a Behavior is present. TheBehavior may choose to delegate child measurement to this method.
- Parameters:
child- child view to lay outlayoutDirection- the resolved layout direction for the CoordinatorLayout, such as or LAYOUT_DIRECTION_RTL.
-
setFitsSystemWindows
void setFitsSystemWindows(boolean fitSystemWindows)
-
dispatchDependentViewsChanged
void dispatchDependentViewsChanged(@NonNull() View view)
Allows the caller to manually dispatch onDependentViewChanged to the associated Behavior instances of views which depend on the provided View.
You should not normally need to call this method as the it will be automatically donewhen the view has changed.
- Parameters:
view- the View to find dependents of to dispatch the call.
-
getDependencies
@NonNull() List<View> getDependencies(@NonNull() View child)
Returns the list of views which the provided view depends on. Do not store this list as itscontents may not be valid beyond the caller.
- Parameters:
child- the view to find dependencies for.
-
getDependents
@NonNull() List<View> getDependents(@NonNull() View child)
Returns the list of views which depend on the provided view. Do not store this list as itscontents may not be valid beyond the caller.
- Parameters:
child- the view to find dependents of.
-
isPointInChildBounds
boolean isPointInChildBounds(@NonNull() View child, int x, int y)
Check if a given point in the CoordinatorLayout's coordinates are within the view bounds of thegiven direct child view.
- Parameters:
child- child view to testx- X coordinate to test, in the CoordinatorLayout's coordinate systemy- Y coordinate to test, in the CoordinatorLayout's coordinate system
-
doViewsOverlap
boolean doViewsOverlap(@NonNull() View first, @NonNull() View second)
Check whether two views overlap each other. The views need to be descendants of this in the view hierarchy.
- Parameters:
first- first child view to testsecond- second child view to test
-
generateLayoutParams
CoordinatorLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
-
onStartNestedScroll
boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
-
onStartNestedScroll
boolean onStartNestedScroll(View child, View target, int axes, int type)
React to a descendant view initiating a nestable scroll operation, claiming thenested scroll operation if appropriate.
This method will be called in response to a descendant view invoking startNestedScroll. Each parent up the view hierarchy will begiven an opportunity to respond and claim the nested scrolling operation by returning
true.This method may be overridden by ViewParent implementations to indicate when the viewis willing to support a nested scrolling operation that is about to begin. If it returnstrue, this ViewParent will become the target view's nested scrolling parent for the durationof the scroll operation in progress. When the nested scroll is finished this ViewParentwill receive a call to onStopNestedScroll.
- Parameters:
child- Direct child of this ViewParent containing targettarget- View that initiated the nested scrollaxes- Flags consisting of SCROLL_AXIS_HORIZONTAL,SCROLL_AXIS_VERTICAL or bothtype- the type of input which cause this scroll event
-
onNestedScrollAccepted
void onNestedScrollAccepted(View child, View target, int nestedScrollAxes)
-
onNestedScrollAccepted
void onNestedScrollAccepted(View child, View target, int nestedScrollAxes, int type)
React to the successful claiming of a nested scroll operation.
This method will be called after onStartNestedScroll returns true. Itoffers an opportunity for the view and its superclasses to perform initial configurationfor the nested scroll. Implementations of this method should always call their superclass'simplementation of this method if one is present.
- Parameters:
child- Direct child of this ViewParent containing targettarget- View that initiated the nested scrolltype- the type of input which cause this scroll event
-
onStopNestedScroll
void onStopNestedScroll(View target)
-
onStopNestedScroll
void onStopNestedScroll(View target, int type)
React to a nested scroll operation ending.
Perform cleanup after a nested scrolling operation.This method will be called when a nested scroll stops, for example when a nested touchscroll ends with a ACTION_UP or ACTION_CANCEL event.Implementations of this method should always call their superclass's implementation of thismethod if one is present.
- Parameters:
target- View that initiated the nested scrolltype- the type of input which cause this scroll event
-
onNestedScroll
void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
-
onNestedScroll
void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type)
React to a nested scroll in progress.
This method will be called when the ViewParent's current nested scrolling child viewdispatches a nested scroll event. To receive calls to this method the ViewParent must havepreviously returned
truefor a call to onStartNestedScroll.Both the consumed and unconsumed portions of the scroll distance are reported to theViewParent. An implementation may choose to use the consumed portion to match or chase scrollposition of multiple child elements, for example. The unconsumed portion may be used toallow continuous dragging of multiple scrolling or draggable elements, such as scrollinga list within a vertical drawer where the drawer begins dragging once the edge of innerscrolling content is reached.
- Parameters:
target- The descendent view controlling the nested scrolldxConsumed- Horizontal scroll distance in pixels already consumed by targetdyConsumed- Vertical scroll distance in pixels already consumed by targetdxUnconsumed- Horizontal scroll distance in pixels not consumed by targetdyUnconsumed- Vertical scroll distance in pixels not consumed by targettype- the type of input which cause this scroll event
-
onNestedScroll
void onNestedScroll(@NonNull() View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @NonNull() Array<int> consumed)
React to a nested scroll in progress.
This method will be called when the ViewParent's current nested scrolling child viewdispatches a nested scroll event. To receive calls to this method the ViewParent must havepreviously returned
truefor a call to onStartNestedScroll.Both the consumed and unconsumed portions of the scroll distance are reported to theViewParent. An implementation may choose to use the consumed portion to match or chase scrollposition of multiple child elements, for example. The unconsumed portion may be used toallow continuous dragging of multiple scrolling or draggable elements, such as scrollinga list within a vertical drawer where the drawer begins dragging once the edge of innerscrolling content is reached.
This method is called when a nested scrolling child invokes dispatchNestedScroll} orone of methods it overloads.
An implementation must report how many pixels of the the x and y scroll distances wereconsumed by this nested scrolling parent by adding the consumed distances to the
consumedparameter. If this View also implements NestedScrollingChild3,consumedshould also be passed up to it's nested scrolling parent so that theparent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1corresponds to dy.- Parameters:
target- The descendant view controlling the nested scrolldxConsumed- Horizontal scroll distance in pixels already consumed by targetdyConsumed- Vertical scroll distance in pixels already consumed by targetdxUnconsumed- Horizontal scroll distance in pixels not consumed by targetdyUnconsumed- Vertical scroll distance in pixels not consumed by targettype- the type of input which cause this scroll eventconsumed- Output.
-
onNestedPreScroll
void onNestedPreScroll(View target, int dx, int dy, Array<int> consumed)
-
onNestedPreScroll
void onNestedPreScroll(View target, int dx, int dy, Array<int> consumed, int type)
React to a nested scroll in progress before the target view consumes a portion of the scroll.
When working with nested scrolling often the parent view may want an opportunityto consume the scroll before the nested scrolling child does. An example of this is adrawer that contains a scrollable list. The user will want to be able to scroll the listfully into view before the list itself begins scrolling.
onNestedPreScrollis called when a nested scrolling child invokes dispatchNestedPreScroll. The implementation shouldreport how any pixels of the scroll reported by dx, dy were consumed in theconsumedarray. Index 0 corresponds to dx and index 1 corresponds to dy.This parameter will never be null. Initial values for consumed[0] and consumed[1]will always be 0.- Parameters:
target- View that initiated the nested scrolldx- Horizontal scroll distance in pixelsdy- Vertical scroll distance in pixelsconsumed- Output.type- the type of input which cause this scroll event
-
onNestedFling
boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
-
onNestedPreFling
boolean onNestedPreFling(View target, float velocityX, float velocityY)
-
getNestedScrollAxes
int getNestedScrollAxes()
-
requestChildRectangleOnScreen
boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
-
-
-
-