The second Android 11 Developer Preview is now available, test it out and share your feedback.

androidx.ui.core

Classes

AlignmentLine

Defines an offset line that can be used by parent layouts to align and position their children.

ComponentNode

The base type for all nodes from the tree generated from a component hierarchy.

Constraints

Immutable constraints used for measuring child Layouts.

ConsumedData

Describes what aspects of, and how much of, a change has been consumed.

DataNode

A ComponentNode that stores a value in the emitted hierarchy

DataNodeKey

The key used in DataNode.

DrawNode

Backing node for the Draw component.

FocusNode

Backing node that implements focus.

HorizontalAlignmentLine

A horizontal AlignmentLine.

LayoutNode

Backing node for Layout component.

LayoutTag

A ParentDataModifier which tags the target with the given tag.

MeasureScope

The receiver scope of a layout's measure lambda.

ModelObserver

Allows for easy model read observation.

Placeable

A Placeable corresponds to a child layout that can be positioned by its parent layout.

PointerId

An ID for a given pointer.

PointerInputChange

Describes a change that has occurred for a particular pointer, as well as how much of the change has been consumed (meaning, used by a node in the UI).

PointerInputData

Data associated with a pointer.

PointerInputNode

Backing node for handling pointer events.

PopupProperties

Ref

SemanticsComponentNode

TransformOrigin

A two-dimensional position represented as a fraction of the Layer's width and height

VerticalAlignmentLine

A vertical AlignmentLine.

Type-aliases

IntrinsicMeasureBlock

A function for performing intrinsic measurement.

MeasureBlock

A function for performing layout measurement.

PointerInputHandler

A function used to react to and modify PointerInputChanges.

Enums

Alignment

Represents a positioning of a point inside a 2D box.

Direction

DropDownAlignment

The DropdownPopup is aligned below its parent relative to its left or right corner.

LayoutDirection

A class for defining layout directions.

PointerEventPass

The enumeration of passes where PointerInputChange traverses up and down the UI tree.

Top-level functions summary

Unit
CoreText(text: AnnotatedString, modifier: Modifier = Modifier.None, style: TextStyle, softWrap: Boolean, overflow: TextOverflow, maxLines: Int, onTextLayout: (TextLayoutResult) -> Unit)

CoreText is a low level element that displays text with multiple different styles.

Unit
CoreTextField(value: InputState, modifier: Modifier, onValueChange: (InputState) -> Unit = { }, textStyle: TextStyle = TextStyle.Default, keyboardType: KeyboardType = KeyboardType.Text, imeAction: ImeAction = ImeAction.Unspecified, onFocus: () -> Unit = {}, onBlur: () -> Unit = {}, focusIdentifier: String? = null, onImeActionPerformed: (ImeAction) -> Unit = {}, visualTransformation: VisualTransformation? = null, onTextLayout: (TextLayoutResult) -> Unit = {})

The common TextField implementation.

Unit
Draw(noinline onPaint: Density.(canvas: Canvas, parentSize: PxSize) -> Unit)

Use Draw to get a Canvas to paint into the parent.

Unit
Draw(crossinline children: () -> Unit, noinline onPaint: DrawReceiver.(canvas: Canvas, parentSize: PxSize) -> Unit)

A Draw scope that accepts children to allow modifying the canvas for children.

Unit
DropdownPopup(dropDownAlignment: DropDownAlignment = DropDownAlignment.Left, offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero), popupProperties: PopupProperties = PopupProperties(), children: () -> Unit)

Opens a popup with the given content.

Unit
Layout(children: () -> Unit, minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock, minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock, maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock, maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock, modifier: Modifier = Modifier.None, measureBlock: MeasureBlock)

Layout is the main core component for layout.

Unit
Layout(children: () -> Unit, modifier: Modifier = Modifier.None, measureBlock: MeasureBlock)

Layout is the main core component for layout.

LayoutNode.MeasureBlocks

Default LayoutNode.MeasureBlocks object implementation, providing intrinsic measurements that use the measure block replacing the measure calls with intrinsic measurement calls.

Unit
OnChildPositioned(noinline onPositioned: (coordinates: LayoutCoordinates) -> Unit, crossinline children: () -> Unit)

onPositioned callback will be called with the final LayoutCoordinates of the children MeasureBox(es) after measuring.

Unit
ParentData(data: Any, crossinline children: () -> Unit)

Provide data for the parent of a Layout, which can then be read from the corresponding Measurable.

Unit
PassThroughLayout(modifier: Modifier = Modifier.None, children: () -> Unit)

Unit
PointerInput(noinline pointerInputHandler: PointerInputHandler, noinline cancelHandler: () -> Unit, noinline initHandler: (CustomEventDispatcher) -> Unit = null, noinline customEventHandler: (CustomEvent, PointerEventPass) -> Unit = null, crossinline children: () -> Unit)

PointerInput is the compose ui core component for receiving and interacting with pointer input.

Unit
Popup(alignment: Alignment = Alignment.TopStart, offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero), popupProperties: PopupProperties = PopupProperties(), children: () -> Unit)

Opens a popup with the given content.

Unit
TestTag(tag: String, children: () -> Unit)

TransformOrigin
TransformOrigin(pivotFractionX: Float, pivotFractionY: Float)

Constructs a TransformOrigin from the given fractional values from the Layer's width and height

Unit
WithConstraints(modifier: Modifier = Modifier.None, children: (Constraints, LayoutDirection) -> Unit)

A composable that defines its own content according to the available space, based on the incoming constraints.

AndroidOwner
createOwner(context: Context)

DrawModifier
draw(onDraw: Density.(canvas: Canvas, size: PxSize) -> Unit)

Creates a DrawModifier that calls onDraw before the contents of the layout.

Modifier
drawClip(shape: Shape)

Clips the content to shape.

Modifier
drawLayer(scaleX: Float = 1f, scaleY: Float = 1f, alpha: Float = 1f, translationX: Float = 0f, translationY: Float = 0f, elevation: Float = 0f, rotationX: Float = 0f, rotationY: Float = 0f, rotationZ: Float = 0f, transformOrigin: TransformOrigin = TransformOrigin.Center, outlineShape: Shape? = null, clipToBounds: Boolean = true, clipToOutline: Boolean = true)

Create a DrawLayerModifier with fixed properties.

Modifier
drawOpacity(opacity: Float)

Makes its children partially transparent.

Modifier
drawShadow(shape: Shape, elevation: Dp, clipToOutline: Boolean = true, opacity: Float = 1f)

Creates a DrawLayerModifier that draws the shadow.

DrawModifier
drawWithContent(onDraw: DrawReceiver.(canvas: Canvas, size: PxSize) -> Unit)

Creates a DrawModifier that allows the developer to draw before or after the layout's contents.

Boolean
isPopupLayout(view: View, testTag: String? = null)

Returns whether the given view is an underlying decor view of a popup.

Modifier
onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit)

Returns a modifier whose onChildPositioned is called with the final LayoutCoordinates of the children Layouts after measuring.

Modifier
onPositioned(onPositioned: (LayoutCoordinates) -> Unit)

Returns modifier whose onPositioned is called with the final LayoutCoordinates of the Layout after measuring.

String
simpleIdentityToString(obj: Any, name: String? = null)

Composition
subcomposeInto(container: ComponentNode, context: Context, parent: CompositionReference? = null, composable: () -> Unit)

Top-level properties summary

ProvidableAmbient<AnimationClockObservable>

ProvidableAmbient<Autofill?>

ProvidableAmbient<AutofillTree>

ProvidableAmbient<Configuration>

ProvidableAmbient<Context>

ProvidableAmbient<CoroutineContext>

ProvidableAmbient<Density>

Modifier

Clips the content to the bounds of the layer.

HorizontalAlignmentLine

AlignmentLine defined by the baseline of a first line of a CoreText.

ProvidableAmbient<FocusManager>

ProvidableAmbient<Font.ResourceLoader>

ProvidableAmbient<HapticFeedback>

The ambient to provide haptic feedback to the user.

HorizontalAlignmentLine

AlignmentLine defined by the baseline of the last line of a CoreText.

ProvidableAmbient<LayoutDirection>

DataNodeKey<(LayoutCoordinates) -> Unit>

DataNodeKey for OnChildPositioned callback

ProvidableAmbient<Owner>

DataNodeKey<Any>

DataNodeKey for ParentData

ProvidableAmbient<TextInputService?>

ProvidableAmbient<UriHandler>

Extension functions summary

For android.app.Activity
Composition
Activity.setContent(content: () -> Unit)

Composes the given composable into the given activity.

Composition
Activity.setViewContent(composable: () -> Unit)

Sets the contentView of an activity to a FrameLayout, and composes the contents of the layout with the passed in composable.

For android.view.ViewGroup
Composition
ViewGroup.setContent(content: () -> Unit)

Composes the given composable into the given view.

Composition
ViewGroup.setViewContent(parent: CompositionReference? = null, composable: () -> Unit)

Composes the children of the view with the passed in composable.

For ComponentNode
Unit

Inserts a child ComponentNode at a last index.

ComponentNode?

Executes selector on every parent of this ComponentNode and returns the closest ComponentNode to return true from selector or null if selector returns false for all ancestors.

LayoutNode?

Executes block on first level of LayoutNode descendants of this ComponentNode and returns the last LayoutNode to return true from block.

Boolean

Returns true if this ComponentNode has no descendant LayoutNodes.

Boolean

Returns true if this ComponentNode currently has an ComponentNode.owner.

Owner

Returns ComponentNode.owner or throws if it is null.

Unit

Executes block on first level of LayoutNode descendants of this ComponentNode.

For PointerInputChange
Boolean

Boolean

Boolean

Boolean

Boolean

PointerInputChange

PointerInputChange
PointerInputChange.consumePositionChange(consumedDx: Px, consumedDy: Px)

PxPosition

PxPosition

Boolean

Boolean

For Painter
DrawModifier
Painter.asModifier(sizeToIntrinsics: Boolean = true, alignment: Alignment = Alignment.Center, scaleFit: ScaleFit = ScaleFit.Fit, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, rtl: Boolean = false)

Create a DrawModifier from this Painter.

For Modifier
Modifier

Clip the content to shape.

Modifier

Clip the content to the bounds of a layer defined at this modifier.

Modifier
Modifier.drawBehind(onDraw: Density.(canvas: Canvas, size: PxSize) -> Unit)

Draw into a Canvas behind the modified content.

Modifier
Modifier.drawLayer(scaleX: Float = 1f, scaleY: Float = 1f, alpha: Float = 1f, translationX: Float = 0f, translationY: Float = 0f, elevation: Float = 0f, rotationX: Float = 0f, rotationY: Float = 0f, rotationZ: Float = 0f, transformOrigin: TransformOrigin = TransformOrigin.Center, outlineShape: Shape? = null, clipToBounds: Boolean = true, clipToOutline: Boolean = true)

Draw the content into a layer.

Modifier

Draw content with modified opacity (alpha) that may be less than 1.

Modifier
Modifier.drawShadow(shape: Shape, elevation: Dp, clipToOutline: Boolean = true, opacity: Float = 1f)

Creates a DrawLayerModifier that draws the shadow.

Modifier
Modifier.onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit)

Invoke onChildPositioned with the LayoutCoordinates of each child element after each one is positioned.

Modifier

Invoke onPositioned with the LayoutCoordinates of the element after positioning.

Modifier
Modifier.paint(painter: Painter, sizeToIntrinsics: Boolean = true, alignment: Alignment = Alignment.Center, scaleFit: ScaleFit = ScaleFit.Fit, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, rtl: Boolean = false)

Paint the content using painter.

Modifier

Tag the element with tag to identify the element within its parent.

For Constraints
IntPxSize

Takes a size and returns the closest size to it that satisfies the constraints.

Constraints
Constraints.enforce(otherConstraints: Constraints)

Returns the result of coercing the current constraints in a different set of constraints.

Constraints
Constraints.offset(horizontal: IntPx = 0.ipx, vertical: IntPx = 0.ipx)

Returns the Constraints obtained by offsetting the current instance with the given values.

Boolean

Takes a size and returns whether it satisfies the current constraints.

For SemanticsNode
SemanticsNode?

Executes selector on every parent of this SemanticsNode and returns the closest SemanticsNode to return true from selector or null if selector returns false for all ancestors.

For AlignmentLine
IntPx
AlignmentLine.merge(position1: IntPx, position2: IntPx)

Merges two values of the current alignment line.

For Rect
Rect

RectF

Extension properties summary

For LayoutCoordinates
PxBounds

The boundaries of this layout inside the root composable.

PxBounds

The global boundaries of this layout inside.

PxPosition

The global position of this layout.

PxPosition

The position of this layout inside the root composable.

For Constraints
Boolean

Whether or not the upper bound on the maximum height.

Boolean

Whether or not the upper bound on the maximum width.

Boolean

Whether there is exactly one height value that satisfies the constraints.

Boolean

Whether there is exactly one width value that satisfies the constraints.

Boolean

Whether the area of a component respecting these constraints will definitely be 0.

For Measurable
Any?

Retrieves the tag associated to a composable with the LayoutTag modifier.

Top-level functions

CoreText

@Composable fun CoreText(
    text: AnnotatedString,
    modifier: Modifier = Modifier.None,
    style: TextStyle,
    softWrap: Boolean,
    overflow: TextOverflow,
    maxLines: Int,
    onTextLayout: (TextLayoutResult) -> Unit
): Unit

CoreText is a low level element that displays text with multiple different styles. The text to display is described using a AnnotatedString. Typically you will instead want to use androidx.ui.foundation.Text, which is a higher level Text element that contains semantics and consumes style information from a theme.

Parameters
text: AnnotatedString AnnotatedString encoding a styled text.
modifier: Modifier = Modifier.None Modifier to apply to this layout node.
style: TextStyle Style configuration for the text such as color, font, line height etc.
softWrap: Boolean Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.
overflow: TextOverflow How visual overflow should be handled.
maxLines: Int An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap. If it is not null, then it must be greater than zero.
onTextLayout: (TextLayoutResult) -> Unit Callback that is executed when a new text layout is calculated.

CoreTextField

@Composable fun CoreTextField(
    value: InputState,
    modifier: Modifier,
    onValueChange: (InputState) -> Unit = { },
    textStyle: TextStyle = TextStyle.Default,
    keyboardType: KeyboardType = KeyboardType.Text,
    imeAction: ImeAction = ImeAction.Unspecified,
    onFocus: () -> Unit = {},
    onBlur: () -> Unit = {},
    focusIdentifier: String? = null,
    onImeActionPerformed: (ImeAction) -> Unit = {},
    visualTransformation: VisualTransformation? = null,
    onTextLayout: (TextLayoutResult) -> Unit = {}
): Unit

The common TextField implementation.

Draw

@Composable inline fun Draw(noinline onPaint: Density.(canvas: Canvas, parentSize: PxSize) -> Unit): Unit

Deprecated.

Use Draw to get a Canvas to paint into the parent.

The onPaint lambda uses a Density receiver scope, to allow easy translation between Dp, Sp, and Px. The parentSize parameter indicates the layout size of the parent.

Deprecated: Draw composable is a common source of bugs as it's not a layout and takes parent size, but doesn't tell you that. Therefore, layout strategies, like androidx.ui.layout.Row or androidx.ui.layout.Column doesn't work with Draw. You should use draw modifier if you want to decorate existent layout with custom drawing, use existent drawing modifiers (androidx.ui.foundation.DrawBackground, androidx.ui.foundation.DrawBorder, Painter.toModifier)or use androidx.ui.foundation.Canvas to make a layout that takes space and allows custom drawing.

Draw

@Composable inline fun Draw(
    crossinline children: () -> Unit,
    noinline onPaint: DrawReceiver.(canvas: Canvas, parentSize: PxSize) -> Unit
): Unit

Deprecated.

A Draw scope that accepts children to allow modifying the canvas for children. The children are drawn when DrawReceiver.drawChildren is called. If the onPaint does not call DrawReceiver.drawChildren then it will be called after the lambda.

Deprecated: Draw composable is a common source of bugs as it's not a layout and takes parent size, but doesn't tell you that. Therefore, layout strategies, like androidx.ui.layout.Row or androidx.ui.layout.Column doesn't work with Draw. You should use drawWithContent modifier if you want to decorate existent layout with custom drawing

DropdownPopup

@Composable fun DropdownPopup(
    dropDownAlignment: DropDownAlignment = DropDownAlignment.Left,
    offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero),
    popupProperties: PopupProperties = PopupProperties(),
    children: () -> Unit
): Unit

Opens a popup with the given content.

The dropdown popup is positioned below its parent, using the dropDownAlignment and offset. The dropdown popup is visible as long as it is part of the composition hierarchy.


//Unresolved: androidx.ui.framework.samples.DropdownPopupSample
Parameters
dropDownAlignment: DropDownAlignment = DropDownAlignment.Left The left or right alignment below the parent.
offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero) An offset from the original aligned position of the popup.
popupProperties: PopupProperties = PopupProperties() Provides extended set of properties to configure the popup.
children: () -> Unit The content to be displayed inside the popup.

Layout

@Composable fun Layout(
    children: () -> Unit,
    minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock,
    minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock,
    maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock,
    maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock,
    modifier: Modifier = Modifier.None,
    measureBlock: MeasureBlock
): Unit

Layout is the main core component for layout. It can be used to measure and position zero or more children.

Intrinsic measurement blocks define the intrinsic sizes of the current layout. These can be queried by the parent in order to understand, in specific cases, what constraints should the layout be measured with:

  • minIntrinsicWidthMeasureBlock defines the minimum width this layout can take, given a specific height, such that the content of the layout will be painted correctly
  • minIntrinsicHeightMeasureBlock defines the minimum height this layout can take, given a specific width, such that the content of the layout will be painted correctly
  • maxIntrinsicWidthMeasureBlock defines the minimum width such that increasing it further will not decrease the minimum intrinsic height
  • maxIntrinsicHeightMeasureBlock defines the minimum height such that increasing it further will not decrease the minimum intrinsic width

For a composable able to define its content according to the incoming constraints, see WithConstraints.

Example usage:


//Unresolved: androidx.ui.framework.samples.LayoutWithProvidedIntrinsicsUsage
Parameters
children: () -> Unit The children composable to be laid out.
modifier: Modifier = Modifier.None Modifiers to be applied to the layout.
minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock The minimum intrinsic width of the layout.
minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock The minimum intrinsic height of the layout.
maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock The maximum intrinsic width of the layout.
maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock The maximum intrinsic height of the layout.
measureBlock: MeasureBlock The block defining the measurement and positioning of the layout.

Layout

@Composable fun Layout(
    children: () -> Unit,
    modifier: Modifier = Modifier.None,
    measureBlock: MeasureBlock
): Unit

Layout is the main core component for layout. It can be used to measure and position zero or more children.

The intrinsic measurements of this layout will be calculated by running the measureBlock, while swapping measure calls with appropriate intrinsic measurements. Note that these provided implementations will not be accurate in all cases - when this happens, the other overload of Layout should be used to provide correct measurements.

For a composable able to define its content according to the incoming constraints, see WithConstraints.

Example usage:


//Unresolved: androidx.ui.framework.samples.LayoutUsage
Parameters
children: () -> Unit The children composable to be laid out.
modifier: Modifier = Modifier.None Modifiers to be applied to the layout.
measureBlock: MeasureBlock The block defining the measurement and positioning of the layout.

MeasuringIntrinsicsMeasureBlocks

fun MeasuringIntrinsicsMeasureBlocks(measureBlock: MeasureBlock): LayoutNode.MeasureBlocks

Default LayoutNode.MeasureBlocks object implementation, providing intrinsic measurements that use the measure block replacing the measure calls with intrinsic measurement calls.

OnChildPositioned

@Composable inline fun OnChildPositioned(
    noinline onPositioned: (coordinates: LayoutCoordinates) -> Unit,
    crossinline children: () -> Unit
): Unit

onPositioned callback will be called with the final LayoutCoordinates of the children MeasureBox(es) after measuring. Note that it will be called after a composition when the coordinates are finalized.

Usage example:


//Unresolved: androidx.ui.framework.samples.OnChildPositionedSample

ParentData

@Composable inline fun ParentData(
    data: Any,
    crossinline children: () -> Unit
): Unit

Deprecated.

Provide data for the parent of a Layout, which can then be read from the corresponding Measurable.

A containing Layout sometimes needs to mark children with attributes that can later be read during layout. data is assigned to the Measurable.parentData to be read. Normally ParentData is completely controlled by the containing Layout. For example, Row and Column layout models use parent data to access the flex value of their children during measurement (though that is achieved using the Inflexible and Flexible modifiers, rather than using this widget).

PassThroughLayout

@Composable fun PassThroughLayout(
    modifier: Modifier = Modifier.None,
    children: () -> Unit
): Unit

Deprecated.

PointerInput

@Composable inline fun PointerInput(
    noinline pointerInputHandler: PointerInputHandler,
    noinline cancelHandler: () -> Unit,
    noinline initHandler: (CustomEventDispatcher) -> Unit = null,
    noinline customEventHandler: (CustomEvent, PointerEventPass) -> Unit = null,
    crossinline children: () -> Unit
): Unit

PointerInput is the compose ui core component for receiving and interacting with pointer input.

Pointer input includes all user input related to 2d positioning on the screen. This includes (but is not necessarily limited to) fingers touching the screen, a mouse moving across the screen, and stylus input.

PointerInput takes the virtual size of all of it's descendant Layout nodes and when a pointer comes in contact with the screen, hit testing is automatically done using that virtual size.

pointerInputHandler is invoked when pointers that have hit tested positive change.

cancelHandler is invoked to notify the handler that no more calls to pointerInputHandler will be made, until at least new pointers exist. This can occur for a few reasons:

  1. Android dispatches ACTION_CANCEL to AndroidComposeView.onTouchEvent.
  2. The PointerInputNode has been removed from the compose hierarchy.
  3. The PointerInputNode no longer has any descendant LayoutNodes and therefore does not know what region of the screen it should virtually exist in.

initHandler is invoked right after the PointerInputNode is hit tested and provides an implementation of CustomEventDispatcher.

customEventHandler is invoked whenever another PointerInput uses CustomEventDispatcher to send a custom event to other PointerInputs.

Parameters
pointerInputHandler: PointerInputHandler Invoked when pointers that have hit this PointerInput change.
cancelHandler: () -> Unit Invoked when a cancellation event occurs.
initHandler: (CustomEventDispatcher) -> Unit = null Invoked when an implementation of CustomEventDispatcher is provided.
customEventHandler: (CustomEvent, PointerEventPass) -> Unit = null Invoked when another PointerInput dispatches a CustomEvent.
children: () -> Unit The children composable that will be composed as a child, or children, of this PointerInput.

Popup

@Composable fun Popup(
    alignment: Alignment = Alignment.TopStart,
    offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero),
    popupProperties: PopupProperties = PopupProperties(),
    children: () -> Unit
): Unit

Opens a popup with the given content.

The popup is positioned relative to its parent, using the alignment and offset. The popup is visible as long as it is part of the composition hierarchy.


//Unresolved: androidx.ui.framework.samples.PopupSample
Parameters
alignment: Alignment = Alignment.TopStart The alignment relative to the parent.
offset: IntPxPosition = IntPxPosition(IntPx.Zero, IntPx.Zero) An offset from the original aligned position of the popup.
popupProperties: PopupProperties = PopupProperties() Provides extended set of properties to configure the popup.
children: () -> Unit The content to be displayed inside the popup.

TestTag

@Composable fun TestTag(
    tag: String,
    children: () -> Unit
): Unit

TransformOrigin

inline fun TransformOrigin(
    pivotFractionX: Float,
    pivotFractionY: Float
): TransformOrigin

Constructs a TransformOrigin from the given fractional values from the Layer's width and height

WithConstraints

@Composable fun WithConstraints(
    modifier: Modifier = Modifier.None,
    children: (Constraints, LayoutDirection) -> Unit
): Unit

A composable that defines its own content according to the available space, based on the incoming constraints. Example usage:


//Unresolved: androidx.ui.framework.samples.WithConstraintsSample
The composable will compose the given children, and will position the resulting layout composablesin a parent Layout. This layout will be as small as possible such that it can fit itschildren. If the composition yields multiple layout children, these will be all placed at thetop left of the WithConstraints, so consider wrapping them in an additional commonparent if different positioning is preferred.
Parameters
modifier: Modifier = Modifier.None Modifier to be applied to the introduced layout.

createOwner

fun createOwner(context: Context): AndroidOwner

This function creates an instance of AndroidOwner

draw

fun draw(onDraw: Density.(canvas: Canvas, size: PxSize) -> Unit): DrawModifier

Deprecated.

Creates a DrawModifier that calls onDraw before the contents of the layout.

drawClip

fun drawClip(shape: Shape): Modifier

Deprecated.

Clips the content to shape.

drawLayer

fun drawLayer(
    scaleX: Float = 1f,
    scaleY: Float = 1f,
    alpha: Float = 1f,
    translationX: Float = 0f,
    translationY: Float = 0f,
    elevation: Float = 0f,
    rotationX: Float = 0f,
    rotationY: Float = 0f,
    rotationZ: Float = 0f,
    transformOrigin: TransformOrigin = TransformOrigin.Center,
    outlineShape: Shape? = null,
    clipToBounds: Boolean = true,
    clipToOutline: Boolean = true
): Modifier

Deprecated.

Create a DrawLayerModifier with fixed properties.


//Unresolved: androidx.ui.core.samples.ChangeOpacity
Parameters
scaleX: Float = 1f DrawLayerModifier.scaleX
scaleY: Float = 1f DrawLayerModifier.scaleY
alpha: Float = 1f DrawLayerModifier.alpha
translationX: Float = 0f DrawLayerModifier.translationX
translationY: Float = 0f DrawLayerModifier.translationY
elevation: Float = 0f DrawLayerModifier.elevation
rotationX: Float = 0f DrawLayerModifier.rotationX
rotationY: Float = 0f DrawLayerModifier.rotationY
rotationZ: Float = 0f DrawLayerModifier.rotationZ
transformOrigin: TransformOrigin = TransformOrigin.Center DrawLayerModifier.transformOrigin
outlineShape: Shape? = null DrawLayerModifier.outlineShape
clipToBounds: Boolean = true DrawLayerModifier.clipToBounds
clipToOutline: Boolean = true DrawLayerModifier.clipToOutline

drawOpacity

fun drawOpacity(opacity: Float): Modifier

Deprecated.

Makes its children partially transparent.

Example usage:


//Unresolved: androidx.ui.framework.samples.OpacitySample
Parameters
opacity: Float the fraction of children's alpha value.

drawShadow

@Composable fun drawShadow(
    shape: Shape,
    elevation: Dp,
    clipToOutline: Boolean = true,
    opacity: Float = 1f
): Modifier

Deprecated.

Creates a DrawLayerModifier that draws the shadow. The elevation defines the visual depth of the physical object. The physical object has a shape specified by shape.

Example usage:


//Unresolved: androidx.ui.framework.samples.DrawShadowSample
Parameters
elevation: Dp The z-coordinate at which to place this physical object.
shape: Shape Defines a shape of the physical object
clipToOutline: Boolean = true When active, the content drawing clips to the outline.
opacity: Float = 1f The opacity of the layer, including the shadow.

drawWithContent

fun drawWithContent(onDraw: DrawReceiver.(canvas: Canvas, size: PxSize) -> Unit): DrawModifier

Creates a DrawModifier that allows the developer to draw before or after the layout's contents. It also allows the modifier to adjust the layout's canvas.

isPopupLayout

@TestOnly fun isPopupLayout(
    view: View,
    testTag: String? = null
): Boolean

Returns whether the given view is an underlying decor view of a popup. If the given testTag is supplied it also verifies that the popup has such tag assigned.

Parameters
view: View View to verify.
testTag: String? = null If provided, tests that the given tag in defined on the popup.

onChildPositioned

fun onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit): Modifier

Deprecated.

Returns a modifier whose onChildPositioned is called with the final LayoutCoordinates of the children Layouts after measuring. Note that it will be called after a composition when the coordinates are finalized.

Usage example:


//Unresolved: androidx.ui.core.samples.OnChildPositionedSample

onPositioned

fun onPositioned(onPositioned: (LayoutCoordinates) -> Unit): Modifier

Deprecated.

Returns modifier whose onPositioned is called with the final LayoutCoordinates of the Layout after measuring. Note that it will be called after a composition when the coordinates are finalized.

Usage example:


//Unresolved: androidx.ui.core.samples.OnPositionedSample

simpleIdentityToString

fun simpleIdentityToString(
    obj: Any,
    name: String? = null
): String

subcomposeInto

@MainThread fun subcomposeInto(
    container: ComponentNode,
    context: Context,
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Top-level properties

AnimationClockAmbient

val AnimationClockAmbient: ProvidableAmbient<AnimationClockObservable>

AutofillAmbient

val AutofillAmbient: ProvidableAmbient<Autofill?>

AutofillTreeAmbient

val AutofillTreeAmbient: ProvidableAmbient<AutofillTree>

ConfigurationAmbient

val ConfigurationAmbient: ProvidableAmbient<Configuration>

ContextAmbient

val ContextAmbient: ProvidableAmbient<Context>

CoroutineContextAmbient

val CoroutineContextAmbient: ProvidableAmbient<CoroutineContext>

DensityAmbient

val DensityAmbient: ProvidableAmbient<Density>

DrawClipToBounds

val DrawClipToBounds: Modifier

Deprecated.

Clips the content to the bounds of the layer.

FirstBaseline

val FirstBaseline: HorizontalAlignmentLine

AlignmentLine defined by the baseline of a first line of a CoreText.

FocusManagerAmbient

val FocusManagerAmbient: ProvidableAmbient<FocusManager>

FontLoaderAmbient

val FontLoaderAmbient: ProvidableAmbient<Font.ResourceLoader>

HapticFeedBackAmbient

val HapticFeedBackAmbient: ProvidableAmbient<HapticFeedback>

The ambient to provide haptic feedback to the user.

LastBaseline

val LastBaseline: HorizontalAlignmentLine

AlignmentLine defined by the baseline of the last line of a CoreText.

LayoutDirectionAmbient

val LayoutDirectionAmbient: ProvidableAmbient<LayoutDirection>

OnChildPositionedKey

val OnChildPositionedKey: DataNodeKey<(LayoutCoordinates) -> Unit>

DataNodeKey for OnChildPositioned callback

OwnerAmbient

val OwnerAmbient: ProvidableAmbient<Owner>

ParentDataKey

val ParentDataKey: DataNodeKey<Any>

DataNodeKey for ParentData

TextInputServiceAmbient

val TextInputServiceAmbient: ProvidableAmbient<TextInputService?>

UriHandlerAmbient

val UriHandlerAmbient: ProvidableAmbient<UriHandler>

Extension functions

add

fun ComponentNode.add(child: ComponentNode): Unit

Inserts a child ComponentNode at a last index. If this ComponentNode isAttached then child will become isAttacheded also. child must have a null ComponentNode.parent.

anyPositionChangeConsumed

fun PointerInputChange.anyPositionChangeConsumed(): Boolean

asModifier

@Composable fun Painter.asModifier(
    sizeToIntrinsics: Boolean = true,
    alignment: Alignment = Alignment.Center,
    scaleFit: ScaleFit = ScaleFit.Fit,
    alpha: Float = DefaultAlpha,
    colorFilter: ColorFilter? = null,
    rtl: Boolean = false
): DrawModifier

Deprecated.

Create a DrawModifier from this Painter. This modifier is memoized and re-used across subsequent compositions


//Unresolved: androidx.ui.framework.samples.PainterModifierSample
Parameters
sizeToIntrinsics: Boolean = true : Flag to indicate whether this PainterModifier should be involved with appropriately sizing the component it is associated with. True if the intrinsic size should influence the size of the component, false otherwise. A value of false here is equivalent to the underlying Painter having no intrinsic size, that is Painter.intrinsicSize returns PxSize.UnspecifiedSize
alignment: Alignment = Alignment.Center : Specifies the rule used to place the contents of the Painter within the specified bounds, the default of Alignment.Center centers the content within the specified rendering bounds
scaleFit: ScaleFit = ScaleFit.Fit : Specifies the rule used to scale the content of the Painter within the specified bounds, the default of ScaleFit.Fit scales the content to be as large as possible within the specified bounds while still maintaining the aspect ratio of its intrinsic size
alpha: Float = DefaultAlpha : Specifies the opacity to render the contents of the underlying Painter
colorFilter: ColorFilter? = null : Specifies an optional tint to apply to the contents of the Painter when drawn in the specified area
rtl: Boolean = false : Flag to indicate contents of the Painter should render for right to left languages

changedToDown

fun PointerInputChange.changedToDown(): Boolean

changedToDownIgnoreConsumed

fun PointerInputChange.changedToDownIgnoreConsumed(): Boolean

changedToUp

fun PointerInputChange.changedToUp(): Boolean

changedToUpIgnoreConsumed

fun PointerInputChange.changedToUpIgnoreConsumed(): Boolean

clip

fun Modifier.clip(shape: Shape): Modifier

Clip the content to shape.

clipToBounds

fun Modifier.clipToBounds(): Modifier

Clip the content to the bounds of a layer defined at this modifier.

constrain

fun Constraints.constrain(size: IntPxSize): IntPxSize

Takes a size and returns the closest size to it that satisfies the constraints.

consumeDownChange

fun PointerInputChange.consumeDownChange(): PointerInputChange

consumePositionChange

fun PointerInputChange.consumePositionChange(
    consumedDx: Px,
    consumedDy: Px
): PointerInputChange

drawBehind

fun Modifier.drawBehind(onDraw: Density.(canvas: Canvas, size: PxSize) -> Unit): Modifier

Draw into a Canvas behind the modified content.

drawLayer

fun Modifier.drawLayer(
    scaleX: Float = 1f,
    scaleY: Float = 1f,
    alpha: Float = 1f,
    translationX: Float = 0f,
    translationY: Float = 0f,
    elevation: Float = 0f,
    rotationX: Float = 0f,
    rotationY: Float = 0f,
    rotationZ: Float = 0f,
    transformOrigin: TransformOrigin = TransformOrigin.Center,
    outlineShape: Shape? = null,
    clipToBounds: Boolean = true,
    clipToOutline: Boolean = true
): Modifier

Draw the content into a layer. This permits applying special effects and transformations:


//Unresolved: androidx.ui.core.samples.ChangeOpacity
Parameters
scaleX: Float = 1f DrawLayerModifier.scaleX
scaleY: Float = 1f DrawLayerModifier.scaleY
alpha: Float = 1f DrawLayerModifier.alpha
elevation: Float = 0f DrawLayerModifier.elevation
rotationX: Float = 0f DrawLayerModifier.rotationX
rotationY: Float = 0f DrawLayerModifier.rotationY
rotationZ: Float = 0f DrawLayerModifier.rotationZ
outlineShape: Shape? = null DrawLayerModifier.outlineShape
clipToBounds: Boolean = true DrawLayerModifier.clipToBounds
clipToOutline: Boolean = true DrawLayerModifier.clipToOutline

drawOpacity

fun Modifier.drawOpacity(opacity: Float): Modifier

Draw content with modified opacity (alpha) that may be less than 1.

Example usage:


//Unresolved: androidx.ui.framework.samples.OpacitySample
Parameters
opacity: Float the fraction of children's alpha value.

drawShadow

@Composable fun Modifier.drawShadow(
    shape: Shape,
    elevation: Dp,
    clipToOutline: Boolean = true,
    opacity: Float = 1f
): Modifier

Creates a DrawLayerModifier that draws the shadow. The elevation defines the visual depth of the physical object. The physical object has a shape specified by shape.

Example usage:


//Unresolved: androidx.ui.framework.samples.DrawShadowSample
Parameters
elevation: Dp The z-coordinate at which to place this physical object.
shape: Shape Defines a shape of the physical object
clipToOutline: Boolean = true When active, the content drawing clips to the outline.
opacity: Float = 1f The opacity of the layer, including the shadow.

enforce

fun Constraints.enforce(otherConstraints: Constraints): Constraints

Returns the result of coercing the current constraints in a different set of constraints.

findClosestParentNode

fun ComponentNode.findClosestParentNode(selector: (ComponentNode) -> Boolean): ComponentNode?

Executes selector on every parent of this ComponentNode and returns the closest ComponentNode to return true from selector or null if selector returns false for all ancestors.

findClosestParentNode

fun SemanticsNode.findClosestParentNode(selector: (SemanticsNode) -> Boolean): SemanticsNode?

Executes selector on every parent of this SemanticsNode and returns the closest SemanticsNode to return true from selector or null if selector returns false for all ancestors.

findLastLayoutChild

fun ComponentNode.findLastLayoutChild(block: (LayoutNode) -> Boolean): LayoutNode?

Executes block on first level of LayoutNode descendants of this ComponentNode and returns the last LayoutNode to return true from block.

hasNoLayoutDescendants

fun ComponentNode.hasNoLayoutDescendants(): Boolean

Returns true if this ComponentNode has no descendant LayoutNodes.

isAttached

fun ComponentNode.isAttached(): Boolean

Returns true if this ComponentNode currently has an ComponentNode.owner. Semantically, this means that the ComponentNode is currently a part of a component tree.

merge

fun AlignmentLine.merge(
    position1: IntPx,
    position2: IntPx
): IntPx

Merges two values of the current alignment line.

offset

fun Constraints.offset(
    horizontal: IntPx = 0.ipx,
    vertical: IntPx = 0.ipx
): Constraints

Returns the Constraints obtained by offsetting the current instance with the given values.

onChildPositioned

fun Modifier.onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit): Modifier

Invoke onChildPositioned with the LayoutCoordinates of each child element after each one is positioned. Note that it will be called after a composition when the coordinates are finalized.

Usage example:


//Unresolved: androidx.ui.core.samples.OnChildPositionedSample

onPositioned

fun Modifier.onPositioned(onPositioned: (LayoutCoordinates) -> Unit): Modifier

Invoke onPositioned with the LayoutCoordinates of the element after positioning. Note that it will be called after a composition when the coordinates are finalized.

Usage example:


//Unresolved: androidx.ui.core.samples.OnPositionedSample

paint

fun Modifier.paint(
    painter: Painter,
    sizeToIntrinsics: Boolean = true,
    alignment: Alignment = Alignment.Center,
    scaleFit: ScaleFit = ScaleFit.Fit,
    alpha: Float = DefaultAlpha,
    colorFilter: ColorFilter? = null,
    rtl: Boolean = false
): Modifier

Paint the content using painter.

Parameters
sizeToIntrinsics: Boolean = true true to size the element relative to Painter.intrinsicSize
alignment: Alignment = Alignment.Center specifies alignment of the painter relative to content
scaleFit: ScaleFit = ScaleFit.Fit strategy for scaling painter if its size does not match the content size
alpha: Float = DefaultAlpha opacity of painter
colorFilter: ColorFilter? = null optional ColorFilter to apply to painter
rtl: Boolean = false layout direction to report to painter when drawing

positionChange

fun PointerInputChange.positionChange(): PxPosition

positionChangeIgnoreConsumed

fun PointerInputChange.positionChangeIgnoreConsumed(): PxPosition

positionChanged

fun PointerInputChange.positionChanged(): Boolean

positionChangedIgnoreConsumed

fun PointerInputChange.positionChangedIgnoreConsumed(): Boolean

requireOwner

fun ComponentNode.requireOwner(): Owner

Returns ComponentNode.owner or throws if it is null.

satisfiedBy

fun Constraints.satisfiedBy(size: IntPxSize): Boolean

Takes a size and returns whether it satisfies the current constraints.

setContent

fun Activity.setContent(content: () -> Unit): Composition

Composes the given composable into the given activity. The composable will become the root view of the given activity.

Note: the returned Composition object is not guaranteed to stay the same between the invocations so it is not safe to use it as a key.

Parameters
content: () -> Unit Composable that will be the content of the activity.

setContent

fun ViewGroup.setContent(content: () -> Unit): Composition

Composes the given composable into the given view.

Note 1: this ViewGroup should have an unique id for the saved instance state mechanism to be able to save and restore the values used within the composition. See View.setId. Note 2: the returned Composition object is not guaranteed to stay the same between the invocations so it is not safe to use it as a key.

Parameters
content: () -> Unit Composable that will be the content of the view.

setViewContent

fun Activity.setViewContent(composable: () -> Unit): Composition

Sets the contentView of an activity to a FrameLayout, and composes the contents of the layout with the passed in composable.

setViewContent

fun ViewGroup.setViewContent(
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Composes the children of the view with the passed in composable.

tag

fun Modifier.tag(tag: Any): Modifier

Tag the element with tag to identify the element within its parent.

toFrameworkRect

fun Rect.toFrameworkRect(): Rect

toFrameworkRectF

fun Rect.toFrameworkRectF(): RectF

visitLayoutChildren

fun ComponentNode.visitLayoutChildren(block: (LayoutNode) -> Unit): Unit

Executes block on first level of LayoutNode descendants of this ComponentNode.

Extension properties

boundsInRoot

val LayoutCoordinates.boundsInRoot: PxBounds

The boundaries of this layout inside the root composable.

globalBounds

val LayoutCoordinates.globalBounds: PxBounds

The global boundaries of this layout inside.

globalPosition

inline val LayoutCoordinates.globalPosition: PxPosition

The global position of this layout.

hasBoundedHeight

val Constraints.hasBoundedHeight: Boolean

Whether or not the upper bound on the maximum height.

See Also

hasBoundedWidth

val Constraints.hasBoundedWidth: Boolean

Whether or not the upper bound on the maximum width.

See Also

hasFixedHeight

val Constraints.hasFixedHeight: Boolean

Whether there is exactly one height value that satisfies the constraints.

hasFixedWidth

val Constraints.hasFixedWidth: Boolean

Whether there is exactly one width value that satisfies the constraints.

isZero

val Constraints.isZero: Boolean

Whether the area of a component respecting these constraints will definitely be 0. This is true when at least one of maxWidth and maxHeight are 0.

positionInRoot

inline val LayoutCoordinates.positionInRoot: PxPosition

The position of this layout inside the root composable.

tag

val Measurable.tag: Any?

Retrieves the tag associated to a composable with the LayoutTag modifier. For a parent data value to be returned by this property when not using the LayoutTag modifier, the parent data value should implement the LayoutTagParentData interface.