Android 12 Developer Preview is here! Try it out, and give us your feedback!

LayoutParams

open class LayoutParams : MarginLayoutParams
kotlin.Any
   ↳ android.view.ViewGroup.LayoutParams
   ↳ android.view.ViewGroup.MarginLayoutParams
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams

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

Summary

Public constructors
<init>(width: Int, height: Int)

Public methods
open Int

Get the id of this view's anchor.

open CoordinatorLayout.Behavior<View!>?

Get the behavior governing the layout and interaction of the child view within a parent CoordinatorLayout.

open Unit
setAnchorId(@IdRes id: Int)

Set the id of this view's anchor.

open Unit

Set the behavior governing the layout and interaction of the child view within a parent CoordinatorLayout.

Properties
Int

A Gravity value describing which edge of a child view's anchor view the child should position itself relative to.

Int

A Gravity value describing how this child view dodges any inset child views in the CoordinatorLayout.

Int

A Gravity value describing how this child view should lay out.

Int

A Gravity value describing how this child view insets the CoordinatorLayout.

Int

The index of the horizontal keyline specified to the parent CoordinatorLayout that this child should align relative to.

Public constructors

<init>

LayoutParams(
    width: Int,
    height: Int)

<init>

LayoutParams(p: CoordinatorLayout.LayoutParams!)

<init>

LayoutParams(p: MarginLayoutParams!)

<init>

LayoutParams(p: LayoutParams!)

Public methods

getAnchorId

@IdRes open fun getAnchorId(): Int

Get the id of this view's anchor.

Return
Int A view id or View#NO_ID if there is no anchor

getBehavior

@Nullable open fun getBehavior(): CoordinatorLayout.Behavior<View!>?

Get the behavior governing the layout and interaction of the child view within a parent CoordinatorLayout.

Return
CoordinatorLayout.Behavior<View!>? The current behavior or null if no behavior is specified

setAnchorId

open fun setAnchorId(@IdRes id: Int): Unit

Set the id of this view's anchor.

The view with this id must be a descendant of the CoordinatorLayout containing the child view this LayoutParams belongs to. It may not be the child view with this LayoutParams or a descendant of it.

Parameters
id Int: The view id of the anchor or View#NO_ID if there is no anchor

setBehavior

open fun setBehavior(@Nullable behavior: CoordinatorLayout.Behavior<View!>?): Unit

Set the behavior governing the layout and interaction of the child view within a parent CoordinatorLayout.

Setting a new behavior will remove any currently associated Behavior tag.

Parameters
behavior CoordinatorLayout.Behavior<View!>?: The behavior to set or null for no special behavior

Properties

anchorGravity

var anchorGravity: Int

A Gravity value describing which edge of a child view's anchor view the child should position itself relative to.

dodgeInsetEdges

var dodgeInsetEdges: Int

A Gravity value describing how this child view dodges any inset child views in the CoordinatorLayout. Any views which are inset on the same edge as this view is set