Google 致力于为黑人社区推动种族平等。查看具体举措

CoordinatorLayout

open class CoordinatorLayout : ViewGroup, NestedScrollingParent2, NestedScrollingParent3
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout

CoordinatorLayout is a super-powered FrameLayout.

CoordinatorLayout is intended for two primary use cases:

  1. As a top-level application decor or chrome layout
  2. 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 using the DefaultBehavior annotation.

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 LayoutParams#insetEdge to describe how the view insets the CoordinatorLayout. Any child views which are set to dodge the same inset edges by LayoutParams#dodgeInsetEdges will be moved appropriately so that the views do not overlap.

Summary

Nested classes
abstract

Defines the default attached Behavior of a View class

abstract

Interaction behavior plugin for child views of CoordinatorLayout.

Defines the default Behavior of a View class.

open

Parameters describing the desired layout for a child of a CoordinatorLayout.

open

Public constructors
<init>(@NonNull context: Context)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, @AttrRes defStyleAttr: Int)

Public methods
open Unit

Allows the caller to manually dispatch Behavior#onDependentViewChanged(CoordinatorLayout, View, View) to the associated Behavior instances of views which depend on the provided View.

open Boolean
doViewsOverlap(@NonNull first: View, @NonNull second: View)

Check whether two views overlap each other.

open CoordinatorLayout.LayoutParams!

open MutableList<View!>
getDependencies(@NonNull child: View)

Returns the list of views which the provided view depends on.

open MutableList<View!>
getDependents(@NonNull child: View)

Returns the list of views which depend on the provided view.

open Int

open Drawable?

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

open Boolean
isPointInChildBounds(@NonNull child: View, x: Int, y: Int)

Check if a given point in the CoordinatorLayout's coordinates are within the view bounds of the given direct child view.

open Unit

open Unit

open Unit

open Boolean

open Unit
onLayoutChild(@NonNull child: View, layoutDirection: Int)

Called to lay out each individual child view unless a Behavior is present.

open Unit
onMeasureChild(child: View!, parentWidthMeasureSpec: Int, widthUsed: Int, parentHeightMeasureSpec: Int, heightUsed: Int)

Called to measure each individual child view unless a Behavior is present.

open Boolean
onNestedFling(target: View, velocityX: Float, velocityY: Float, consumed: Boolean)

open Boolean
onNestedPreFling(target: View, velocityX: Float, velocityY: Float)

open Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray)

open Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray, type: Int)

open Unit
onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int)

open Unit
onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int)

open Unit
onNestedScroll(@NonNull target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int, @NonNull consumed: IntArray)

open Unit
onNestedScrollAccepted(child: View, target: View, nestedScrollAxes: Int)

open Unit