Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

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 to dodge will result in this view being moved so that the views do not overlap.

gravity

var gravity: Int

A Gravity value describing how this child view should lay out. If either or both of the axes are not specified, they are treated by CoordinatorLayout as Gravity#TOP or GravityCompat#START. If an anchor is also specified, the gravity describes how this child view should be positioned relative to its anchored position.

insetEdge

var insetEdge: Int

A Gravity value describing how this child view insets the CoordinatorLayout. Other child views which are set to dodge the same inset edges will be moved appropriately so that the views do not overlap.

keyline

var keyline: Int

The index of the horizontal keyline specified to the parent CoordinatorLayout that this child should align relative to. If an anchor is present the keyline will be ignored.