androidx.ui.core

Classes

AlignmentLine

Defines a layout line that can be used by layout models to align and position layout children.

AndroidComposeView

Bounds

A four dimensional bounds using Dp for units

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.

Density

A density of the screen.

Dp

Dimension value representing device-independent pixels (dp).

DpCubed

Holds a unit of cubed dimensions, such as 1.value * 2.value * 3.dp.

DpInverse

Holds a unit of an inverse dimensions, such as 1.dp / (2.value * 3.dp).

DpSquared

Holds a unit of squared dimensions, such as 1.value * 2.dp.

DrawNode

Backing node for the Draw component.

Duration

A span of time, such as 27 days, 4 hours, 12 minutes, and 3 seconds.

EditorModel

A class holding information about the editing state.

FocusNode

Backing node that implements focus.

HorizontalAlignmentLine

A horizontal AlignmentLine.

IntPx

Dimension value represented in whole pixels (px).

IntPxBounds

A four dimensional bounds using IntPx for units

IntPxPosition

A two-dimensional position using IntPx for units

IntPxSize

A two dimensional size using IntPx for units

LayoutNode

Backing node for Layout component.

MeasureScope

The receiver scope of a layout's measure lambda.

MultiComposableMeasurables

A List of Measurables passed in as the argument to the Layout measureBlock when using the vararg variant.

Placeable

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

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

Position

A two-dimensional position using Dp for units

Px

Dimension value represented in pixels (px).

PxBounds

A four dimensional bounds using Px for units

PxCubed

Holds a unit of cubed dimensions, such as 1.value * 2.value * 3.px.

PxInverse

Holds a unit of an inverse dimensions, such as 1.px / (2.value * 3.px).

PxPosition

A two-dimensional position using Px for units

PxSize

A two dimensional size using Px for units

PxSquared

Holds a unit of squared dimensions, such as 1.value * 2.px.

Ref

RepaintBoundaryNode

SemanticsComponentNode

SemanticsTreeNodeImpl

Represent a node in the semantics tree together with information about its parent and children.

Size

A two dimensional size using Dp for units

TextSpanComposer

The composer of TextSpan.

TextSpanComposition

TextSpanScope

The receiver class of the children of Text and TextSpan.

TextUnit

The unit used for text related dimension value.

Timestamp

A single point in time expressed in nanoseconds.

Velocity

A velocity in two dimensions.

VerticalAlignmentLine

A vertical AlignmentLine.

Type-aliases

IntrinsicMeasureBlock

A function for performing intrinsic measurement.

MeasureBlock

A function for performing layout measurement.

MultiMeasureBlock

PointerInputHandler

TextSpanUpdater

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.

TextUnitType

An enum class defining for type of thextUnit.

Top-level constants summary

const Long

const Long

const Long

const Long

const Long

const Long

Top-level functions summary

Unit
Clip(shape: Shape, crossinline children: () -> Unit)

Clips the children with the provided shape.

Unit
ComposeView(children: () -> Unit)

Composes a view containing ui composables into a view composition.

Unit
CurrentTextStyleProvider(value: TextStyle, children: () -> Unit)

This component is used to set the current value of the Text style ambient.

Density
Density(context: Context)

Creates a Density from this Context

DensityScope

Returns a DensityScope reflecting density.

Unit
Draw(noinline onPaint: DensityScope.(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
DrawShadow(shape: Shape, elevation: Dp)

Draws the shadow.

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.

Duration
Duration(days: Long = 0, hours: Long = 0, minutes: Long = 0, seconds: Long = 0, milliseconds: Long = 0, microseconds: Long = 0, nanoseconds: Long = 0)

Constructs a Duration given a series of time intervals in different units.

IntPxPosition

Constructs a IntPxPosition from x and y position IntPx values.

IntPxSize
IntPxSize(width: IntPx, height: IntPx)

Constructs an IntPxSize from width and height IntPx values.

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.

Unit
Layout(vararg childrenArray: () -> Unit, modifier: Modifier = Modifier.None, measureBlock: MultiMeasureBlock)

Temporary component that allows composing and indexing measurables of multiple composables.

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
OnPositioned(noinline onPositioned: (coordinates: LayoutCoordinates) -> Unit)

onPositioned callback will be called with the final LayoutCoordinates of the parent MeasureBox after measuring.

Unit
Opacity(opacity: Float, crossinline children: () -> Unit)

Makes its children partially transparent.

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
PasswordTextField(value: String, onValueChange: (String) -> Unit = {}, textStyle: TextStyle? = null, mask: Char = '\u2022', imeAction: ImeAction = ImeAction.Unspecified, onFocus: () -> Unit = {}, onBlur: () -> Unit = {}, focusIdentifier: String? = null, onImeActionPerformed: (ImeAction) -> Unit = {})

A user interface element for entering and modifying password text.

Unit
PointerInputWrapper(noinline pointerInputHandler: PointerInputHandler = { event, _, _ -> event }, noinline cancelHandler: () -> Unit = {}, crossinline children: () -> Unit)

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

Opens a popup with the given content.

Position
Position(x: Dp, y: Dp)

Constructs a Position from x and y position Dp values.

PxPosition

Create a PxPosition from IntPx values.

PxPosition
PxPosition(x: Px, y: Px)

Constructs a PxPosition from x and y position Px values.

PxSize
PxSize(width: IntPx, height: IntPx)

Create a PxSize from IntPx values.

PxSize
PxSize(width: Px, height: Px)

Constructs a PxSize from width and height Px values.

Unit
RepaintBoundary(name: String? = null, children: () -> Unit)

A repaint boundary blocks parents from having to repaint when contained children are invalidated.

Size
Size(width: Dp, height: Dp)

Constructs a Size from width and height Dp values.

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

Unit
Text(modifier: Modifier = Modifier.None, style: TextStyle? = null, paragraphStyle: ParagraphStyle? = null, softWrap: Boolean = DefaultSoftWrap, overflow: TextOverflow = DefaultOverflow, maxLines: Int? = DefaultMaxLines, child: TextSpanScope.() -> Unit)

The Text composable displays text that uses multiple different styles.

Unit
Text(text: String, modifier: Modifier = Modifier.None, style: TextStyle? = null, paragraphStyle: ParagraphStyle? = null, softWrap: Boolean = DefaultSoftWrap, overflow: TextOverflow = DefaultOverflow, maxLines: Int? = DefaultMaxLines)

Simplified version of Text component with minimal set of customizations.

Unit
Text(text: AnnotatedString, modifier: Modifier = Modifier.None, style: TextStyle? = null, paragraphStyle: ParagraphStyle? = null, softWrap: Boolean = DefaultSoftWrap, overflow: TextOverflow = DefaultOverflow, maxLines: Int? = DefaultMaxLines)

The Text composable displays text that uses multiple different styles.

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

A user interface element for entering and modifying text.

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

A user interface element for entering and modifying text.

Unit
TextField(model: EditorModel, compositionRange: TextRange?, modifier: Modifier = Modifier.None, onValueChange: (EditorModel, TextRange?) -> Unit = { _, _ -> }, textStyle: TextStyle? = null, keyboardType: KeyboardType = KeyboardType.Text, imeAction: ImeAction = ImeAction.Unspecified, onFocus: () -> Unit = {}, onBlur: () -> Unit = {}, focusIdentifier: String? = null, onImeActionPerformed: (ImeAction) -> Unit = {}, visualTransformation: VisualTransformation? = null)

A user interface element for entering and modifying text.

Unit
WithConstraints(children: (Constraints) -> Unit)

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

Unit
WithDensity(block: DensityScope.() -> Unit)

A component to be able to convert dimensions between each other.

Effect<Density>

ambient to get a Density object from an internal DensityAmbient.

Unit
compose(container: TextSpan, parent: CompositionReference? = null, composable: TextSpanScope.() -> Unit)

Compose a TextSpan tree.

Effect<TextStyle>

This effect is used to read the current value of the Text style ambient.

Unit

Disposes the root view of the Activity.

Unit
disposeComposition(container: TextSpan, parent: CompositionReference? = null)

Cleanup when the TextSpan is no longer used.

Unit
ifDebug(block: () -> Unit)

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

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

Dp
lerp(start: Dp, stop: Dp, fraction: Float)

Linearly interpolate between two Dps.

Position
lerp(start: Position, stop: Position, fraction: Float)

Linearly interpolate between two Positions.

IntPx
lerp(start: IntPx, stop: IntPx, fraction: Float)

Linearly interpolate between two IntPxs.

IntPxPosition
lerp(start: IntPxPosition, stop: IntPxPosition, fraction: Float)

Linearly interpolate between two IntPxPositions.

Px
lerp(start: Px, stop: Px, fraction: Float)

Linearly interpolate between two Pxs.

PxPosition
lerp(start: PxPosition, stop: PxPosition, fraction: Float)

Linearly interpolate between two PxPositions.

TextUnit

Dp
max(a: Dp, b: Dp)

IntPx
max(a: IntPx, b: IntPx)

Return the maximum of two IntPxs.

Px
max(a: Px, b: Px)

TextUnit

Returns the smaller value from the given values.

Dp
min(a: Dp, b: Dp)

IntPx
min(a: IntPx, b: IntPx)

Return the minimum of two IntPxs.

Px
min(a: Px, b: Px)

TextUnit

Returns the smaller value from the given values.

Long
packFloats(val1: Float, val2: Float)

Packs two Float values into one Long value for use in inline classes.

Long
packInts(val1: Int, val2: Int)

Packs two Int values into one Long value for use in inline classes.

Float

Unpacks the first Float value in packFloats from its returned Long.

Float

Unpacks the second Float value in packFloats from its returned Long.

Int
unpackInt1(value: Long)

Unpacks the first Int value in packInts from its returned ULong.

Int
unpackInt2(value: Long)

Unpacks the second Int value in packInts from its returned ULong.

R
withDensity(density: Density, block: DensityScope.() -> R)

If you have a Density object and you want to perform some conversions use this.

Top-level properties summary

Ambient<AndroidComposeView>

Ambient<AnimationClockObservable>

Ambient<Autofill?>

Ambient<AutofillTree>

Ambient<Configuration>

Ambient<Context>

Ambient<CoroutineContext>

String

Ambient<Density>

HorizontalAlignmentLine

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

Ambient<FocusManager>

Ambient<Font.ResourceLoader>

HorizontalAlignmentLine

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

Ambient<LayoutDirection>

Long

Long

Long

Long

Long

DataNodeKey<(LayoutCoordinates) -> Unit>

DataNodeKey for OnChildPositioned callback

DataNodeKey<(LayoutCoordinates) -> Unit>

DataNodeKey for OnPositioned callback

DataNodeKey<Any>

DataNodeKey for ParentData

Ambient<String>

Ambient<TextInputService?>

Extension functions summary

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

Composes the given composable into the given activity.

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

Composes the given composable into the given view.

For kotlin.Double
operator DpInverse
Double.div(other: Dp)

operator PxInverse
Double.div(other: Px)

operator Dp
Double.times(other: Dp)

operator Size
Double.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Double.times(other: IntPx)

Multiply an IntPx by a Double and round the result to an IntPx.

operator Px
Double.times(other: Px)

operator PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Float
operator DpInverse
Float.div(other: Dp)

operator PxInverse
Float.div(other: Px)

operator Dp
Float.times(other: Dp)

operator Size
Float.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Float.times(other: IntPx)

Multiply an IntPx by a Float and round the result to an IntPx.

operator Px
Float.times(other: Px)

operator PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Int
operator DpInverse
Int.div(other: Dp)

operator PxInverse
Int.div(other: Px)

operator Dp
Int.times(other: Dp)

operator Size
Int.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Int.times(other: IntPx)

Multiply an IntPx by a Double to result in an IntPx.

operator IntPxSize

Returns an IntPxSize with size's IntPxSize.width and IntPxSize.height multiplied by this

operator Px
Int.times(other: Px)

operator PxSize
Int.times(size: PxSize)

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit
Int.times(other: TextUnit)

Multiply a TextUnit by a scalar.

For kotlin.Long
Timestamp

Convert a Long value in milliseconds to a Timestamp.

Timestamp

Convert a Long value in nanoseconds to a Timestamp.

Timestamp

Convert a Long value in seconds to a Timestamp.

For TextSpanScope
Unit
TextSpanScope.Span(text: String? = null, style: TextStyle? = null, child: TextSpanScope.() -> Unit)

Unit
TextSpanScope.Span(text: String? = null, style: TextStyle? = null)

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 Size
Position

Returns the Position of the center of the rect from the point of 0,0 with this Size.

Bounds

Convert a Size to a Bounds.

For IntPxSize
IntPxPosition

Returns the IntPxPosition of the center of the rect from the point of 0,0 with this IntPxSize.

PxSize

Convert a IntPxSize to a PxSize

For PxSize
PxPosition

Returns the PxPosition of the center of the rect from the point of 0,0 with this PxSize.

PxBounds

Convert a PxSize to a PxBounds.

Rect

Convert a PxSize to a Rect.

For LayoutNode
PxPosition

Converts a child LayoutNode position into a local position within this LayoutNode.

PxPosition
LayoutNode.globalToLocal(global: PxPosition, withOwnerOffset: Boolean = true)

Converts a PxPosition relative to a global context into a PxPosition that is relative to this LayoutNode.

IntPxPosition
LayoutNode.globalToLocal(global: IntPxPosition, withOwnerOffset: Boolean = true)

Converts a IntPxPosition relative to a global context into a IntPxPosition that is relative to this LayoutNode.

PxPosition
LayoutNode.localToGlobal(local: PxPosition, withOwnerOffset: Boolean = true)

Converts an PxPosition that is relative to this LayoutNode into one that is relative to a more global context.

IntPxPosition
LayoutNode.localToGlobal(local: IntPxPosition, withOwnerOffset: Boolean = true)

Converts an IntPxPosition that is relative to this LayoutNode into one that is relative to a more global context.

PxPosition

Calculates the position of this LayoutNode relative to the provided ancestor.

IntPxPosition

Calculates the position of this LayoutNode relative to the root of the ui tree.

For Dp
Dp
Dp.coerceAtLeast(minimumValue: Dp)

Ensures that this value is not less than the specified minimumValue.

Dp
Dp.coerceAtMost(maximumValue: Dp)

Ensures that this value is not greater than the specified maximumValue.

Dp
Dp.coerceIn(minimumValue: Dp, maximumValue: Dp)

Ensures that this value lies in the specified range minimumValue.

Boolean

Return true when it is finite or false when it is Dp.Infinity

For IntPx
IntPx
IntPx.coerceAtLeast(minimumValue: IntPx)

Ensures that this value is not less than the specified minimumValue.

IntPx
IntPx.coerceAtMost(maximumValue: IntPx)

Ensures that this value is not greater than the specified maximumValue.

IntPx
IntPx.coerceIn(minimumValue: IntPx, maximumValue: IntPx)

Ensures that this value lies in the specified range minimumValue.

Boolean

Return whether true when it is finite or false when it is IntPx.Infinity

Px

For Px
Px
Px.coerceAtLeast(minimumValue: Px)

Ensures that this value is not less than the specified minimumValue.

Px
Px.coerceAtMost(maximumValue: Px)

Ensures that this value is not greater than the specified maximumValue.

Px
Px.coerceIn(minimumValue: Px, maximumValue: Px)

Ensures that this value lies in the specified range minimumValue.

IntPx

Rounds a Px size to the nearest Int pixel value.

For TextUnit
TextUnit

Ensures that the value of TextUnit is not less than the specified minimumValue.

TextUnit

Ensures that the value of TextUnit is not greater than the specified maximumValue.

TextUnit
TextUnit.coerceIn(minimumValue: TextUnit, maximumValue: TextUnit)

Ensures that the value of TextUnit lies in the specified range minimumValue.

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

Returns a copy of the current instance with no max constraints.

Constraints

Returns a copy of the current instance with no min 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.

Constraints

Returns a copy of the current instance with the constraints tightened to their largest size.

Constraints

Returns a copy of the current instance with the constraints tightened to their smallest size.

Constraints
Constraints.withTight(width: IntPx? = null, height: IntPx? = null)

Returns a copy of the current instance, overriding the specified values to be tight.

For Position
Dp

The magnitude of the offset represented by this Position.

For PxPosition
Px

The magnitude of the offset represented by this PxPosition.

IntPxPosition

Round a PxPosition down to the nearest Int coordinates.

Offset

Convert a PxPosition to a Offset.

For Duration
Long

Returns the number of whole days spanned by this Duration.

Long

Returns the number of whole hours spanned by this Duration.

Long

Returns number of whole microseconds spanned by this Duration.

Long

Returns number of whole milliseconds spanned by this Duration.

Long

Returns the number of whole minutes spanned by this Duration.

Long

Returns the number of whole seconds spanned by this Duration.

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

Merges two values of the current alignment line.

For Velocity
operator Velocity

Return the difference of two velocities.

operator Velocity

Return the sum of two velocities.

For Rect
Rect

RectF

For IntPxPosition
PxPosition

Convert a IntPxPosition to a PxPosition

For PxBounds
Rect

Convert a PxBounds to a Rect.

PxSize

Convert a PxBounds to a PxSize.

For Bounds
Size

Convert a Bounds to a Size.

For IntPxBounds
IntPxSize

Convert a IntPxBounds to a IntPxSize.

Extension properties summary

For kotlin.Double
Dp

Create a Dp using a Double: val left = 10.

TextUnit

Creates an EM unit TextUnit

Px

Create a Px using a Double: val left = 10.

TextUnit

Creates a SP unit TextUnit

For kotlin.Float
Dp

Create a Dp using a Float: val left = 10f val x = left.

TextUnit

Creates an EM unit TextUnit

Px

Create a Px using a Float: val left = 10f val x = left.

TextUnit

Creates a SP unit TextUnit

For kotlin.Int
Duration

Dp

Create a Dp using an Int: val left = 10 val x = left.

TextUnit

Creates an EM unit TextUnit

Duration

IntPx

Create a IntPx using an Int: val left = 10 val x = left.

Duration

Duration

Duration

Duration

Px

Create a Px using an Int: val left = 10 val x = left.

Duration

TextUnit

Creates a SP unit TextUnit

For kotlin.Long
Duration

Duration

Duration

Duration

Duration

Duration

Duration

For LayoutCoordinates
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 there is exactly one size that satisfies the constraints.

Boolean

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

For Bounds
Dp

A height of this Bounds in Dp.

Dp

A width of this Bounds in Dp.

For IntPxBounds
IntPx

A height of this IntPxBounds in IntPx.

IntPx

A width of this IntPxBounds in IntPx.

For PxBounds
Px

A height of this PxBounds in Px.

Px

A width of this PxBounds in Px.

For PxSize
Px

Returns the smallest dimension size.

Top-level constants

HoursPerDay

const val HoursPerDay: Long
Value: 24L

MicrosecondsPerMillisecond

const val MicrosecondsPerMillisecond: Long
Value: 1000L

MillisecondsPerSecond

const val MillisecondsPerSecond: Long
Value: 1000L

MinutesPerHour

const val MinutesPerHour: Long
Value: 60L

NanosecondsPerMicrosecond

const val NanosecondsPerMicrosecond: Long
Value: 1000L

SecondsPerMinute

const val SecondsPerMinute: Long
Value: 60L

Top-level functions

Clip

@Composable inline fun Clip(
    shape: Shape,
    crossinline children: () -> Unit
): Unit

Clips the children with the provided shape.

Parameters
shape: Shape the Shape used for clipping.

ComposeView

@Composable fun ComposeView(children: () -> Unit): Unit

Composes a view containing ui composables into a view composition.

CurrentTextStyleProvider

@Composable fun CurrentTextStyleProvider(
    value: TextStyle,
    children: () -> Unit
): Unit

This component is used to set the current value of the Text style ambient. The given style will be merged with the current style values for any missing attributes. Any Text components included in this component's children will be styled with this style unless styled explicitly.

Density

fun Density(context: Context): Density

Creates a Density from this Context

DensityScope

fun DensityScope(density: Density): DensityScope

Returns a DensityScope reflecting density.

Draw

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

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

Example usage:

import androidx.compose.memo
import androidx.ui.core.Draw
import androidx.ui.core.toRect
import androidx.ui.graphics.Paint

val paint = +memo { Paint() }
Draw { canvas, parentSize ->
    paint.color = Color.Black
    canvas.drawRect(parentSize.toRect(), paint)
}
The onPaint lambda uses a DensityScope receiver scope, to allow easy translationbetween Dp, Sp, and Px. The parentSize parameter indicates the layout size ofthe parent.

Draw

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

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.

Example usage:

import androidx.compose.memo
import androidx.ui.core.Draw
import androidx.ui.core.Text
import androidx.ui.core.toRect
import androidx.ui.engine.geometry.Rect
import androidx.ui.graphics.Paint

val children = @Composable {
    Text("Hello World")
}
val paint = +memo { Paint() }
Draw(children) { canvas, parentSize ->
    // Draw the highlight behind the text
    paint.color = Color.Yellow
    paint.style = PaintingStyle.fill
    val rect = parentSize.toRect()
    canvas.drawRect(rect, paint)

    // Draw the text
    drawChildren()

    // Draw the border on top of the text
    paint.style = PaintingStyle.stroke
    val strokeWidth = 2.dp.toIntPx().value.toFloat()
    paint.color = Color.Black
    paint.strokeWidth = strokeWidth
    val outlineRect = Rect(
        left = strokeWidth / 2,
        top = strokeWidth / 2,
        right = rect.right - (strokeWidth / 2),
        bottom = rect.bottom - (strokeWidth / 2)
    )
    canvas.drawRect(outlineRect, paint)
}

DrawShadow

@Composable inline fun DrawShadow(
    shape: Shape,
    elevation: Dp
): Unit

Draws the shadow. The elevation defines the visual dept of the physical object. The physical object has a shape specified by shape.

Example usage:

import androidx.ui.core.DrawShadow

DrawShadow(shape = RectangleShape, elevation = 12.dp)
Parameters
elevation: Dp The z-coordinate at which to place this physical object.
shape: Shape Defines a shape of the physical object

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.

import androidx.ui.core.DropdownPopup
import androidx.ui.foundation.shape.DrawShape
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.Container

val parentWidth = 400.dp
val parentHeight = 200.dp
Container(width = parentWidth, height = parentHeight) {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    // The popup will appear below the parent
    DropdownPopup(dropDownAlignment = DropDownAlignment.Left) {
        // Draw a rectangle shape with rounded corners inside the popup
        Container(width = popupWidth, height = popupHeight) {
            DrawShape(RoundedCornerShape(cornerSize), Color.White)
        }
    }
}
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.

Duration

fun Duration(
    days: Long = 0,
    hours: Long = 0,
    minutes: Long = 0,
    seconds: Long = 0,
    milliseconds: Long = 0,
    microseconds: Long = 0,
    nanoseconds: Long = 0
): Duration

Constructs a Duration given a series of time intervals in different units.

IntPxPosition

inline fun IntPxPosition(
    x: IntPx,
    y: IntPx
): IntPxPosition

Constructs a IntPxPosition from x and y position IntPx values.

IntPxSize

inline fun IntPxSize(
    width: IntPx,
    height: IntPx
): IntPxSize

Constructs an IntPxSize from width and height IntPx values.

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:

import androidx.ui.core.Constraints
import androidx.ui.core.Layout

// We build a layout that will occupy twice as much space as its children,
// and will position them to be bottom right aligned.
Layout(
    children,
    minIntrinsicWidthMeasureBlock = { measurables, h ->
        // The min intrinsic width of this layout will be twice the largest min intrinsic
        // width of a child. Note that we call minIntrinsicWidth with h / 2 for children,
        // since we should be double the size of the children.
        (measurables.map { it.minIntrinsicWidth(h / 2) }.maxBy { it.value } ?: 0.ipx) * 2
    },
    minIntrinsicHeightMeasureBlock = { measurables, w ->
        (measurables.map { it.minIntrinsicHeight(w / 2) }.maxBy { it.value } ?: 0.ipx) * 2
    },
    maxIntrinsicWidthMeasureBlock = { measurables, h ->
        (measurables.map { it.maxIntrinsicHeight(h / 2) }.maxBy { it.value } ?: 0.ipx) * 2
    },
    maxIntrinsicHeightMeasureBlock = { measurables, w ->
        (measurables.map { it.maxIntrinsicHeight(w / 2) }.maxBy { it.value } ?: 0.ipx) * 2
    }
) { measurables, constraints ->
    // measurables contains one element corresponding to each of our layout children.
    // constraints are the constraints that our parent is currently measuring us with.
    val childConstraints = Constraints(
        minWidth = constraints.minWidth / 2,
        minHeight = constraints.minHeight / 2,
        maxWidth = constraints.maxWidth / 2,
        maxHeight = constraints.maxHeight / 2
    )
    // We measure the children with half our constraints, to ensure we can be double
    // the size of the children.
    val placeables = measurables.map { it.measure(childConstraints) }
    val layoutWidth = (placeables.maxBy { it.width.value }?.width ?: 0.ipx) * 2
    val layoutHeight = (placeables.maxBy { it.height.value }?.height ?: 0.ipx) * 2
    // We call layout to set the size of the current layout and to provide the positioning
    // of the children. The children are placed relative to the current layout place.
    layout(layoutWidth, layoutHeight) {
        placeables.forEach { it.place(layoutWidth - it.width, layoutHeight - it.height) }
    }
}
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:

import androidx.ui.core.Constraints
import androidx.ui.core.Layout

// We build a layout that will occupy twice as much space as its children,
// and will position them to be bottom right aligned.
Layout(children) { measurables, constraints ->
    // measurables contains one element corresponding to each of our layout children.
    // constraints are the constraints that our parent is currently measuring us with.
    val childConstraints = Constraints(
        minWidth = constraints.minWidth / 2,
        minHeight = constraints.minHeight / 2,
        maxWidth = constraints.maxWidth / 2,
        maxHeight = constraints.maxHeight / 2
    )
    // We measure the children with half our constraints, to ensure we can be double
    // the size of the children.
    val placeables = measurables.map { it.measure(childConstraints) }
    val layoutWidth = (placeables.maxBy { it.width.value }?.width ?: 0.ipx) * 2
    val layoutHeight = (placeables.maxBy { it.height.value }?.height ?: 0.ipx) * 2
    // We call layout to set the size of the current layout and to provide the positioning
    // of the children. The children are placed relative to the current layout place.
    layout(layoutWidth, layoutHeight) {
        placeables.forEach { it.place(layoutWidth - it.width, layoutHeight - it.height) }
    }
}
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.

Layout

@Composable fun Layout(
    vararg childrenArray: () -> Unit,
    modifier: Modifier = Modifier.None,
    measureBlock: MultiMeasureBlock
): Unit

Temporary component that allows composing and indexing measurables of multiple composables. The logic here will be moved back to Layout, which will accept vararg children argument.

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:

import androidx.ui.core.OnChildPositioned

Column {
    SizedRectangle(color = Color.Green, width = 20.dp, height = 20.dp)
    OnChildPositioned(onPositioned = { coordinates ->
        // This will be the size of the child SizedRectangle.
        coordinates.size
        // This will be the position of SizedRectangle inside its Column parent.
        coordinates.position
        // The position of the SizedRectangle relative to the application window.
        coordinates.globalPosition
        // The position of the SizedRectangle relative to the Compose root.
        coordinates.positionInRoot
        // These will be the alignment lines provided to the layout (empty for SizedRectangle)
        coordinates.providedAlignmentLines
        // This will a LayoutCoordinates instance corresponding to the Column.
        coordinates.parentCoordinates
    }) {
        SizedRectangle(color = Color.Blue, width = 20.dp, height = 20.dp)
    }
}

OnPositioned

@Composable inline fun OnPositioned(noinline onPositioned: (coordinates: LayoutCoordinates) -> Unit): Unit

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

Usage example:

import androidx.ui.core.OnPositioned

Column {
    SizedRectangle(color = Color.Green, width = 20.dp, height = 20.dp)
    SizedRectangle(color = Color.Blue, width = 20.dp, height = 20.dp)
    OnPositioned(onPositioned = { coordinates ->
        // This will be the size of the Column.
        coordinates.size
        // This will be the position of Column inside its parent.
        coordinates.position
        // The position of the Column relative to the application window.
        coordinates.globalPosition
        // The position of the Column relative to the Compose root.
        coordinates.positionInRoot
        // These will be the alignment lines provided to the layout (empty here for Column).
        coordinates.providedAlignmentLines
        // This will a LayoutCoordinates instance corresponding to the parent of Column.
        coordinates.parentCoordinates
    })
}

Opacity

@Composable inline fun Opacity(
    opacity: Float,
    crossinline children: () -> Unit
): Unit

Makes its children partially transparent.

Example usage:

import androidx.ui.core.Opacity
import androidx.ui.foundation.shape.DrawShape

Opacity(opacity = 0.5f) {
    DrawShape(RectangleShape, Color.Red)
}
Parameters
opacity: Float the fraction of children's alpha value.

ParentData

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

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).

Example usage:

import androidx.ui.core.Layout
import androidx.ui.core.ParentData

val parentDataComposable = @Composable {
    ParentData(data = 5) {
        SizedRectangle(color = Color.Blue, width = 50.dp, height = 50.dp)
    }
}
Layout(parentDataComposable) { measurables, constraints ->
    // The parentData will be 5.
    measurables[0].parentData as Int
    layout(constraints.maxWidth, constraints.maxHeight) {}
}

PasswordTextField

@Composable fun PasswordTextField(
    value: String,
    onValueChange: (String) -> Unit = {},
    textStyle: TextStyle? = null,
    mask: Char = '\u2022',
    imeAction: ImeAction = ImeAction.Unspecified,
    onFocus: () -> Unit = {},
    onBlur: () -> Unit = {},
    focusIdentifier: String? = null,
    onImeActionPerformed: (ImeAction) -> Unit = {}
): Unit

A user interface element for entering and modifying password text.

The PasswordTextField component renders an input with masking characters, i.e. bullet. Once input service modify the text, you will get callback onValueChange with new text. Then, you can set this new text so that this component renders up-to-date text from input service.

Example usage:

import androidx.compose.state
import androidx.ui.core.PasswordTextField

val state = +state { "" }
PasswordTextField(
    value = state.value,
    onValueChange = { state.value = it }
)
Parameters
value: String The text to be shown in the TextField. If you want to specify cursor location or selection range, use TextField with EditorModel instead.
onValueChange: (String) -> Unit = {} Called when the input service updates the text. When the input service update the text, this callback is called with the updated text. If you want to observe the cursor location or selection range, use TextField with EditorModel instead.
textStyle: TextStyle? = null Style configuration that applies at character level such as color, font etc.
mask: Char = '\u2022' The character shown instead of plaint text.
imeAction: ImeAction = ImeAction.Unspecified The IME action. This IME action is honored by IME and may show specific icons on the keyboard. For example, search icon may be shown if ImeAction.Search is specified. Then, when user tap that key, the onImeActionPerformed callback is called with specified ImeAction.
onFocus: () -> Unit = {} Called when the input field gains focus.
onBlur: () -> Unit = {} Called when the input field loses focus.
focusIdentifier: String? = null Optional value to identify focus identifier. You can pass FocusManager.requestFocus to this value to move focus to this TextField. This identifier must be unique in your app. If you have duplicated identifiers, the behavior is undefined.
onImeActionPerformed: (ImeAction) -> Unit = {} Called when the input service requested an IME action. When the input service emitted an IME action, this callback is called with the emitted IME action. Note that this IME action may be different from what you specified in imeAction.

PointerInputWrapper

@Composable inline fun PointerInputWrapper(
    noinline pointerInputHandler: PointerInputHandler = { event, _, _ -> event },
    noinline cancelHandler: () -> Unit = {},
    crossinline children: () -> Unit
): Unit

Popup

@Composable fun Popup(
    alignment: Alignment = Alignment.TopLeft,
    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.

import androidx.ui.core.Popup
import androidx.ui.foundation.shape.DrawShape
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.Container

Container {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Container(width = popupWidth, height = popupHeight) {
            DrawShape(RoundedCornerShape(cornerSize), Color.White)
        }
    }
}
Parameters
alignment: Alignment = Alignment.TopLeft 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.

Position

inline fun Position(
    x: Dp,
    y: Dp
): Position

Constructs a Position from x and y position Dp values.

PxPosition

inline fun PxPosition(
    x: IntPx,
    y: IntPx
): PxPosition

Create a PxPosition from IntPx values.

PxPosition

inline fun PxPosition(
    x: Px,
    y: Px
): PxPosition

Constructs a PxPosition from x and y position Px values.

PxSize

inline fun PxSize(
    width: IntPx,
    height: IntPx
): PxSize

Create a PxSize from IntPx values.

PxSize

inline fun PxSize(
    width: Px,
    height: Px
): PxSize

Constructs a PxSize from width and height Px values.

RepaintBoundary

@Composable fun RepaintBoundary(
    name: String? = null,
    children: () -> Unit
): Unit

A repaint boundary blocks parents from having to repaint when contained children are invalidated. This is used when children are invalidated together and don't affect the parent. For example, a Button with a contained ripple does not need to invalidate its container when animating the ripple.

Parameters
name: String? = null The (optional) name of the RepaintBoundary. This is used for debugging and will be given to the tag on a View or the name of a RenderNode.
children: () -> Unit The contained children.

Size

inline fun Size(
    width: Dp,
    height: Dp
): Size

Constructs a Size from width and height Dp values.

TestTag

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

Text

@Composable fun Text(
    modifier: Modifier = Modifier.None,
    style: TextStyle? = null,
    paragraphStyle: ParagraphStyle? = null,
    softWrap: Boolean = DefaultSoftWrap,
    overflow: TextOverflow = DefaultOverflow,
    maxLines: Int? = DefaultMaxLines,
    child: TextSpanScope.() -> Unit
): Unit

The Text composable displays text that uses multiple different styles. The text to display is described using a tree of Span, each of which has an associated style that is used for that subtree. The text might break across multiple lines or might all be displayed on the same line depending on the layout constraints.

Parameters
modifier: Modifier = Modifier.None Modifier to apply to this layout node.
style: TextStyle? = null Style configuration that applies at character level such as color, font etc.
paragraphStyle: ParagraphStyle? = null Style configuration that applies only to paragraphs such as text alignment, or text direction.
softWrap: Boolean = DefaultSoftWrap 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 = DefaultOverflow How visual overflow should be handled.
maxLines: Int? = DefaultMaxLines 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.

Text

@Composable fun Text(
    text: String,
    modifier: Modifier = Modifier.None,
    style: TextStyle? = null,
    paragraphStyle: ParagraphStyle? = null,
    softWrap: Boolean = DefaultSoftWrap,
    overflow: TextOverflow = DefaultOverflow,
    maxLines: Int? = DefaultMaxLines
): Unit

Simplified version of Text component with minimal set of customizations.

Parameters
text: String The text to be displayed.
modifier: Modifier = Modifier.None Modifier to apply to this layout node.
style: TextStyle? = null Style configuration that applies at character level such as color, font etc.
paragraphStyle: ParagraphStyle? = null Style configuration that applies only to paragraphs such as text alignment, or text direction.
softWrap: Boolean = DefaultSoftWrap 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 = DefaultOverflow How visual overflow should be handled.
maxLines: Int? = DefaultMaxLines 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.

Text

@Composable fun Text(
    text: AnnotatedString,
    modifier: Modifier = Modifier.None,
    style: TextStyle? = null,
    paragraphStyle: ParagraphStyle? = null,
    softWrap: Boolean = DefaultSoftWrap,
    overflow: TextOverflow = DefaultOverflow,
    maxLines: Int? = DefaultMaxLines
): Unit

The Text composable displays text that uses multiple different styles. The text to display is described using a AnnotatedString.

Parameters
text: AnnotatedString AnnotatedString encoding a styled text.
modifier: Modifier = Modifier.None Modifier to apply to this layout node.
style: TextStyle? = null Style configuration that applies at character level such as color, font etc.
paragraphStyle: ParagraphStyle? = null Style configuration that applies only to paragraphs such as text alignment, or text direction.
softWrap: Boolean = DefaultSoftWrap 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 = DefaultOverflow How visual overflow should be handled.
maxLines: Int? = DefaultMaxLines 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.

TextField

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

A user interface element for entering and modifying text.

The TextField component renders an input and additional decorations set by input service which is software keyboard in Android. Once input service modify the text, you will get callback onValueChange with new text. Then, you can set this new text so that this component renders up-to-date text from input service.

Example usage:

import androidx.compose.state
import androidx.ui.core.TextField

val state = +state { "" }
TextField(
    value = state.value,
    onValueChange = { state.value = it }
)

This is the most simple TextField that observes only text update and have control only for the text. If you want to change/observe the selection/cursor location, you can use TextField with EditorModel object.

Note: Please be careful if you setting text other than the one passed to onValueChange callback. Especially, it is not recommended to modify the text passed to onValueChange callback. The text change may be translated to full context reset by input service and end up with input session restart. This will be visible to users, for example, any ongoing composition text will be cleared or committed, then software keyboard may go back to the default one.

Parameters
value: String The text to be shown in the TextField. If you want to specify cursor location or selection range, use TextField with EditorModel instead.
onValueChange: (String) -> Unit = {} Called when the input service updates the text. When the input service update the text, this callback is called with the updated text. If you want to observe the cursor location or selection range, use TextField with EditorModel instead.
textStyle: TextStyle? = null Style configuration that applies at character level such as color, font etc.
keyboardType: KeyboardType = KeyboardType.Text The keyboard type to be used in this text field. Note that this input type is honored by IME and shows corresponding keyboard but this is not guaranteed. For example, some IME may send non-ASCII character even if you set KeyboardType.Ascii.
imeAction: ImeAction = ImeAction.Unspecified The IME action. This IME action is honored by IME and may show specific icons on the keyboard. For example, search icon may be shown if ImeAction.Search is specified. Then, when user tap that key, the onImeActionPerformed callback is called with specified ImeAction.
onFocus: () -> Unit = {} Called when the input field gains focus.
onBlur: () -> Unit = {} Called when the input field loses focus.
focusIdentifier: String? = null Optional value to identify focus identifier. You can pass FocusManager.requestFocus to this value to move focus to this TextField. This identifier must be unique in your app. If you have duplicated identifiers, the behavior is undefined.
onImeActionPerformed: (ImeAction) -> Unit = {} Called when the input service requested an IME action. When the input service emitted an IME action, this callback is called with the emitted IME action. Note that this IME action may be different from what you specified in imeAction.
visualTransformation: VisualTransformation? = null Optional visual filter for changing visual output of input field.

TextField

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

A user interface element for entering and modifying text.

The TextField component renders an input and additional decorations set by input service which is software keyboard in Android. Once input service modify the text, you will get callback onValueChange with new text. Then, you can set this new text so that this component renders up-to-date text from input service.

Example usage:

import androidx.compose.state
import androidx.ui.core.EditorModel
import androidx.ui.core.TextField

val state = +state { EditorModel() }
TextField(
    value = state.value,
    onValueChange = { state.value = it }
)
Note: Please be careful if you setting model other than the one passed to onValueChangecallback including selection or cursor. Especially, it is not recommended to modify the modelpassed to onValueChange callback. Any change to text, selection or cursor may be translated tofull context reset by input service and end up with input session restart. This will be visibleto users, for example, any ongoing composition text will be cleared or committed, then softwarekeyboard may go back to the default one.
Parameters
value: EditorModel The EditorModel to be shown in the TextField.
onValueChange: (EditorModel) -> Unit = {} Called when the input service updates the text, selection or cursor. When the input service update the text, selection or cursor, this callback is called with the updated EditorModel. If you want to observe the composition text, use TextField with compositionRange instead.
textStyle: TextStyle? = null Style configuration that applies at character level such as color, font etc.
keyboardType: KeyboardType = KeyboardType.Text The keyboard type to be used in this text field. Note that this input type is honored by IME and shows corresponding keyboard but this is not guaranteed. For example, some IME may send non-ASCII character even if you set KeyboardType.Ascii.
imeAction: ImeAction = ImeAction.Unspecified The IME action. This IME action is honored by IME and may show specific icons on the keyboard. For example, search icon may be shown if ImeAction.Search is specified. Then, when user tap that key, the onImeActionPerformed callback is called with specified ImeAction.
onFocus: () -> Unit = {} Called when the input field gains focus.
onBlur: () -> Unit = {} Called when the input field loses focus.
focusIdentifier: String? = null Optional value to identify focus identifier. You can pass FocusManager.requestFocus to this value to move focus to this TextField. This identifier must be unique in your app. If you have duplicated identifiers, the behavior is undefined.
onImeActionPerformed: (ImeAction) -> Unit = {} Called when the input service requested an IME action. When the input service emitted an IME action, this callback is called with the emitted IME action. Note that this IME action may be different from what you specified in imeAction.
visualTransformation: VisualTransformation? = null Optional visual filter for changing visual output of input field.

TextField

@Composable fun TextField(
    model: EditorModel,
    compositionRange: TextRange?,
    modifier: Modifier = Modifier.None,
    onValueChange: (EditorModel, TextRange?) -> Unit = { _, _ -> },
    textStyle: TextStyle? = null,
    keyboardType: KeyboardType = KeyboardType.Text,
    imeAction: ImeAction = ImeAction.Unspecified,
    onFocus: () -> Unit = {},
    onBlur: () -> Unit = {},
    focusIdentifier: String? = null,
    onImeActionPerformed: (ImeAction) -> Unit = {},
    visualTransformation: VisualTransformation? = null
): Unit

A user interface element for entering and modifying text.

The TextField component renders an input and additional decorations set by input service which is software keyboard in Android. Once input service modify the text, you will get callback onValueChange with new text. Then, you can set this new text so that this component renders up-to-date text from input service.

Example usage:

import androidx.compose.state
import androidx.ui.core.EditorModel
import androidx.ui.core.TextField

val model = +state { EditorModel() }
val composition = +state<TextRange?> { null }
TextField(
    model = model.value,
    compositionRange = composition.value,
    onValueChange = { newModel, newComposition ->
        model.value = newModel
        composition.value = newComposition
    }
)

It is not recommended to use this component unless you are interested in composition region. The composition text is set by input service and you don't have control of it. If you modify composition, the input service may confuse and restart new input session. Also please do not expect no composition range at the beginning of input session. The input service may convert existing text to composition text at the beginning of the input session.

Note: Please be careful if you setting model other than the one passed to onValueChange callback including selection or cursor. Especially, it is not recommended to modify the model passed to onValueChange callback. Any change to text, selection or cursor may be translated to full context reset by input service and end up with input session restart. This will be visible to users, for example, any ongoing composition text will be cleared or committed, then software keyboard may go back to the default one.

Parameters
model: EditorModel The EditorModel to be shown in the TextField.
onValueChange: (EditorModel, TextRange?) -> Unit = { _, _ -> } Called when the input service updates the text, selection or cursor. When the input service update the text, selection or cursor, this callback is called with the updated EditorModel.
textStyle: TextStyle? = null Style configuration that applies at character level such as color, font etc.
keyboardType: KeyboardType = KeyboardType.Text The keyboard type to be used in this text field. Note that this input type is honored by IME and shows corresponding keyboard but this is not guaranteed. For example, some IME may send non-ASCII character even if you set KeyboardType.Ascii.
imeAction: ImeAction = ImeAction.Unspecified The IME action. This IME action is honored by IME and may show specific icons on the keyboard. For example, search icon may be shown if ImeAction.Search is specified. Then, when user tap that key, the onImeActionPerformed callback is called with specified ImeAction.
onFocus: () -> Unit = {} Called when the input field gains focus.
onBlur: () -> Unit = {} Called when the input field loses focus.
focusIdentifier: String? = null Optional value to identify focus identifier. You can pass FocusManager.requestFocus to this value to move focus to this TextField. This identifier must be unique in your app. If you have duplicated identifiers, the behavior is undefined.
onImeActionPerformed: (ImeAction) -> Unit = {} Called when the input service requested an IME action. When the input service emitted an IME action, this callback is called with the emitted IME action. Note that this IME action may be different from what you specified in imeAction.
visualTransformation: VisualTransformation? = null Optional visual filter for changing visual output of input field.

WithConstraints

@Composable fun WithConstraints(children: (Constraints) -> Unit): Unit

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

import androidx.ui.core.WithConstraints
import androidx.ui.core.ambientDensity
import androidx.ui.core.withDensity

WithConstraints { constraints ->
    val rectangleHeight = 100.dp
    val threshold = withDensity(+ambientDensity()) { (rectangleHeight * 2).toIntPx() }
    if (constraints.maxHeight < threshold) {
        SizedRectangle(color = Color.Blue, width = 50.dp, height = rectangleHeight)
    } else {
        Column {
            SizedRectangle(color = Color.Blue, width = 50.dp, height = rectangleHeight)
            SizedRectangle(color = Color.Gray, width = 50.dp, height = rectangleHeight)
        }
    }
}
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.

WithDensity

@Composable fun WithDensity(block: DensityScope.() -> Unit): Unit

A component to be able to convert dimensions between each other. A Density object will be take from an ambient.

Usage example: WithDensity { Draw() { canvas, _ -> canvas.drawRect(Rect(0, 0, dpHeight.toPx(), dpWidth.toPx()), paint) } }

ambientDensity

@CheckResult("+") fun ambientDensity(): Effect<Density>

ambient to get a Density object from an internal DensityAmbient.

Note: this is an experiment with the ways to achieve a read-only public Ambients.

compose

fun compose(
    container: TextSpan,
    parent: CompositionReference? = null,
    composable: TextSpanScope.() -> Unit
): Unit

Compose a TextSpan tree.

Parameters
container: TextSpan The root of TextSpan tree where the children TextSpans will be attached to.
parent: CompositionReference? = null The parent composition reference, if applicable. Default is null.
composable: TextSpanScope.() -> Unit The composable function to compose the children of container.

currentTextStyle

fun currentTextStyle(): Effect<TextStyle>

This effect is used to read the current value of the Text style ambient. Any Text components included in this component's children will be styled with this style unless styled explicitly.

disposeActivityComposition

fun disposeActivityComposition(activity: Activity): Unit

Disposes the root view of the Activity.

disposeComposition

fun disposeComposition(
    container: TextSpan,
    parent: CompositionReference? = null
): Unit

Cleanup when the TextSpan is no longer used.

Parameters
container: TextSpan The root of the TextSpan to be disposed.
parent: CompositionReference? = null The CompositionReference used together with container when composer is called.

ifDebug

inline fun ifDebug(block: () -> Unit): Unit

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.

lerp

fun lerp(
    start: Dp,
    stop: Dp,
    fraction: Float
): Dp

Linearly interpolate between two Dps.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: Position,
    stop: Position,
    fraction: Float
): Position

Linearly interpolate between two Positions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: IntPx,
    stop: IntPx,
    fraction: Float
): IntPx

Linearly interpolate between two IntPxs.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

If start or stop is IntPx.Infinity, then IntPx.Infinity is returned.

lerp

fun lerp(
    start: IntPxPosition,
    stop: IntPxPosition,
    fraction: Float
): IntPxPosition

Linearly interpolate between two IntPxPositions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: Px,
    stop: Px,
    fraction: Float
): Px

Linearly interpolate between two Pxs.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: PxPosition,
    stop: PxPosition,
    fraction: Float
): PxPosition

Linearly interpolate between two PxPositions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerpTextUnit

fun lerpTextUnit(
    a: TextUnit,
    b: TextUnit,
    t: Float
): TextUnit

max

inline fun max(
    a: Dp,
    b: Dp
): Dp

max

inline fun max(
    a: IntPx,
    b: IntPx
): IntPx

Return the maximum of two IntPxs. An IntPx.Infinity is considered the maximum value.

max

inline fun max(
    a: Px,
    b: Px
): Px

max

inline fun max(
    a: TextUnit,
    b: TextUnit
): TextUnit

Returns the smaller value from the given values.

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

min

inline fun min(
    a: Dp,
    b: Dp
): Dp

min

inline fun min(
    a: IntPx,
    b: IntPx
): IntPx

Return the minimum of two IntPxs. Any value is considered less than IntPx.Infinity.

min

inline fun min(
    a: Px,
    b: Px
): Px

min

inline fun min(
    a: TextUnit,
    b: TextUnit
): TextUnit

Returns the smaller value from the given values.

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

packFloats

inline fun packFloats(
    val1: Float,
    val2: Float
): Long

Packs two Float values into one Long value for use in inline classes.

packInts

inline fun packInts(
    val1: Int,
    val2: Int
): Long

Packs two Int values into one Long value for use in inline classes.

unpackFloat1

inline fun unpackFloat1(value: Long): Float

Unpacks the first Float value in packFloats from its returned Long.

unpackFloat2

inline fun unpackFloat2(value: Long): Float

Unpacks the second Float value in packFloats from its returned Long.

unpackInt1

inline fun unpackInt1(value: Long): Int

Unpacks the first Int value in packInts from its returned ULong.

unpackInt2

inline fun unpackInt2(value: Long): Int

Unpacks the second Int value in packInts from its returned ULong.

withDensity

fun <R> withDensity(
    density: Density,
    block: DensityScope.() -> R
): R

If you have a Density object and you want to perform some conversions use this.


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

Top-level properties

AndroidComposeViewAmbient

val AndroidComposeViewAmbient: Ambient<AndroidComposeView>

AnimationClockAmbient

val AnimationClockAmbient: Ambient<AnimationClockObservable>

AutofillAmbient

val AutofillAmbient: Ambient<Autofill?>

AutofillTreeAmbient

val AutofillTreeAmbient: Ambient<AutofillTree>

ConfigurationAmbient

val ConfigurationAmbient: Ambient<Configuration>

ContextAmbient

val ContextAmbient: Ambient<Context>

CoroutineContextAmbient

val CoroutineContextAmbient: Ambient<CoroutineContext>

DefaultTestTag

val DefaultTestTag: String

DensityAmbient

val DensityAmbient: Ambient<Density>

FirstBaseline

val FirstBaseline: HorizontalAlignmentLine

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

FocusManagerAmbient

val FocusManagerAmbient: Ambient<FocusManager>

FontLoaderAmbient

val FontLoaderAmbient: Ambient<Font.ResourceLoader>

LastBaseline

val LastBaseline: HorizontalAlignmentLine

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

LayoutDirectionAmbient

val LayoutDirectionAmbient: Ambient<LayoutDirection>

NanosecondsPerDay

val NanosecondsPerDay: Long

NanosecondsPerHour

val NanosecondsPerHour: Long

NanosecondsPerMillisecond

val NanosecondsPerMillisecond: Long

NanosecondsPerMinute

val NanosecondsPerMinute: Long

NanosecondsPerSecond

val NanosecondsPerSecond: Long

OnChildPositionedKey

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

DataNodeKey for OnChildPositioned callback

OnPositionedKey

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

DataNodeKey for OnPositioned callback

ParentDataKey

val ParentDataKey: DataNodeKey<Any>

DataNodeKey for ParentData

TestTagAmbient

val TestTagAmbient: Ambient<String>

TextInputServiceAmbient

val TextInputServiceAmbient: Ambient<TextInputService?>

Extension functions

Span

@Composable fun TextSpanScope.Span(
    text: String? = null,
    style: TextStyle? = null,
    child: TextSpanScope.() -> Unit
): Unit

Span

@Composable fun TextSpanScope.Span(
    text: String? = null,
    style: TextStyle? = null
): Unit

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

center

fun Size.center(): Position

Returns the Position of the center of the rect from the point of 0,0 with this Size.

center

fun IntPxSize.center(): IntPxPosition

Returns the IntPxPosition of the center of the rect from the point of 0,0 with this IntPxSize.

center

fun PxSize.center(): PxPosition

Returns the PxPosition of the center of the rect from the point of 0,0 with this PxSize.

changedToDown

fun PointerInputChange.changedToDown(): Boolean

changedToDownIgnoreConsumed

fun PointerInputChange.changedToDownIgnoreConsumed(): Boolean

changedToUp

fun PointerInputChange.changedToUp(): Boolean

changedToUpIgnoreConsumed

fun PointerInputChange.changedToUpIgnoreConsumed(): Boolean

childToLocal

fun LayoutNode.childToLocal(
    child: LayoutNode,
    childLocal: PxPosition
): PxPosition

Converts a child LayoutNode position into a local position within this LayoutNode.

coerceAtLeast

inline fun Dp.coerceAtLeast(minimumValue: Dp): Dp

Ensures that this value is not less than the specified minimumValue.

Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun IntPx.coerceAtLeast(minimumValue: IntPx): IntPx

Ensures that this value is not less than the specified minimumValue.

Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun Px.coerceAtLeast(minimumValue: Px): Px

Ensures that this value is not less than the specified minimumValue.

Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun TextUnit.coerceAtLeast(minimumValue: TextUnit): TextUnit

Ensures that the value of TextUnit is not less than the specified minimumValue.

Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtMost

inline fun Dp.coerceAtMost(maximumValue: Dp): Dp

Ensures that this value is not greater than the specified maximumValue.

Return
this value if it's less than or equal to the maximumValue or the maximumValue otherwise.

coerceAtMost

inline fun IntPx.coerceAtMost(maximumValue: IntPx): IntPx

Ensures that this value is not greater than the specified maximumValue.

Return
this value if it's less than or equal to the maximumValue or the maximumValue otherwise. Passing IntPx.Infinity as maximumValue will always return this.

coerceAtMost

inline fun Px.coerceAtMost(maximumValue: Px): Px

Ensures that this value is not greater than the specified maximumValue.

Return
this value if it's less than or equal to the maximumValue or the maximumValue otherwise.

coerceAtMost

inline fun TextUnit.coerceAtMost(maximumValue: TextUnit): TextUnit

Ensures that the value of TextUnit is not greater than the specified maximumValue.

Return
this value if it's less than or equal to the maximumValue or the maximumValue otherwise.

coerceIn

inline fun Dp.coerceIn(
    minimumValue: Dp,
    maximumValue: Dp
): Dp

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

inline fun IntPx.coerceIn(
    minimumValue: IntPx,
    maximumValue: IntPx
): IntPx

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

inline fun Px.coerceIn(
    minimumValue: Px,
    maximumValue: Px
): Px

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

inline fun TextUnit.coerceIn(
    minimumValue: TextUnit,
    maximumValue: TextUnit
): TextUnit

Ensures that the value of TextUnit lies in the specified range minimumValue..maximumValue.

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

Return
this value if it's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

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

div

inline operator fun Double.div(other: Dp): DpInverse

div

inline operator fun Double.div(other: Px): PxInverse

div

inline operator fun Float.div(other: Dp): DpInverse

div

inline operator fun Float.div(other: Px): PxInverse

div

inline operator fun Int.div(other: Dp): DpInverse

div

inline operator fun Int.div(other: Px): PxInverse

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.

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.

getDistance

fun Position.getDistance(): Dp

The magnitude of the offset represented by this Position.

getDistance

fun PxPosition.getDistance(): Px

The magnitude of the offset represented by this PxPosition.

globalToLocal

fun LayoutNode.globalToLocal(
    global: PxPosition,
    withOwnerOffset: Boolean = true
): PxPosition

Converts a PxPosition relative to a global context into a PxPosition that is relative to this LayoutNode.

If withOwnerOffset is true (which is the default), the global parameter is interpreted as being a position relative to the application window. Otherwise, the global parameter is interpreted to be relative to the root of the compose context.

globalToLocal

fun LayoutNode.globalToLocal(
    global: IntPxPosition,
    withOwnerOffset: Boolean = true
): IntPxPosition

Converts a IntPxPosition relative to a global context into a IntPxPosition that is relative to this LayoutNode.

If withOwnerOffset is true (which is the default), the global parameter is interpreted as being a position relative to the application window. Otherwise, the global parameter is interpreted to be relative to the root of the compose context.

hasNoLayoutDescendants

fun ComponentNode.hasNoLayoutDescendants(): Boolean

Returns true if this ComponentNode has no descendant LayoutNodes.

inDays

fun Duration.inDays(): Long

Returns the number of whole days spanned by this Duration.

inHours

fun Duration.inHours(): Long

Returns the number of whole hours spanned by this Duration.

The returned value can be greater than 23.

inMicroseconds

fun Duration.inMicroseconds(): Long

Returns number of whole microseconds spanned by this Duration.

inMilliseconds

fun Duration.inMilliseconds(): Long

Returns number of whole milliseconds spanned by this Duration.

The returned value can be greater than 999.

inMinutes

fun Duration.inMinutes(): Long

Returns the number of whole minutes spanned by this Duration.

The returned value can be greater than 59.

inSeconds

fun Duration.inSeconds(): Long

Returns the number of whole seconds spanned by this Duration.

The returned value can be greater than 59.

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.

isFinite

inline fun Dp.isFinite(): Boolean

Return true when it is finite or false when it is Dp.Infinity

isFinite

inline fun IntPx.isFinite(): Boolean

Return whether true when it is finite or false when it is IntPx.Infinity

localToGlobal

fun LayoutNode.localToGlobal(
    local: PxPosition,
    withOwnerOffset: Boolean = true
): PxPosition

Converts an PxPosition that is relative to this LayoutNode into one that is relative to a more global context.

If withOwnerOffset is true (which is the default), the return value will be relative to the application window. Otherwise, the location is relative to the root of the compose context.

localToGlobal

fun LayoutNode.localToGlobal(
    local: IntPxPosition,
    withOwnerOffset: Boolean = true
): IntPxPosition

Converts an IntPxPosition that is relative to this LayoutNode into one that is relative to a more global context.

If withOwnerOffset is true (which is the default), the return value will be relative to the app window. Otherwise, the location is relative to the root of the compose context.

looseMax

fun Constraints.looseMax(): Constraints

Returns a copy of the current instance with no max constraints.

looseMin

fun Constraints.looseMin(): Constraints

Returns a copy of the current instance with no min constraints.

merge

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

Merges two values of the current alignment line.

millisecondsToTimestamp

fun Long.millisecondsToTimestamp(): Timestamp

Convert a Long value in milliseconds to a Timestamp.

minus

operator fun Velocity.minus(other: Velocity): Velocity

Return the difference of two velocities.

nanosecondsToTimestamp

fun Long.nanosecondsToTimestamp(): Timestamp

Convert a Long value in nanoseconds to a Timestamp.

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.

plus

operator fun Velocity.plus(other: Velocity): Velocity

Return the sum of two velocities.

positionChange

fun PointerInputChange.positionChange(): PxPosition

positionChangeIgnoreConsumed

fun PointerInputChange.positionChangeIgnoreConsumed(): PxPosition

positionChanged

fun PointerInputChange.positionChanged(): Boolean

positionChangedIgnoreConsumed

fun PointerInputChange.positionChangedIgnoreConsumed(): Boolean

positionRelativeToAncestor

fun LayoutNode.positionRelativeToAncestor(ancestor: LayoutNode): PxPosition

Calculates the position of this LayoutNode relative to the provided ancestor.

positionRelativeToRoot

fun LayoutNode.positionRelativeToRoot(): IntPxPosition

Calculates the position of this LayoutNode relative to the root of the ui tree.

requireOwner

fun ComponentNode.requireOwner(): Owner

Returns ComponentNode.owner or throws if it is null.

round

inline fun Px.round(): IntPx

Rounds a Px size to the nearest Int pixel value.

round

inline fun PxPosition.round(): IntPxPosition

Round a PxPosition down to the nearest Int coordinates.

satisfiedBy

fun Constraints.satisfiedBy(size: IntPxSize): Boolean

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

secondsToTimestamp

fun Long.secondsToTimestamp(): Timestamp

Convert a Long value in seconds to a Timestamp.

setContent

fun Activity.setContent(content: () -> Unit): CompositionContext?

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

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

setContent

fun ViewGroup.setContent(content: () -> Unit): CompositionContext?

Composes the given composable into the given view.

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

tightMax

fun Constraints.tightMax(): Constraints

Returns a copy of the current instance with the constraints tightened to their largest size. Note that if any of the constraints are unbounded, they will be left unchanged.

tightMin

fun Constraints.tightMin(): Constraints

Returns a copy of the current instance with the constraints tightened to their smallest size.

times

inline operator fun Double.times(other: Dp): Dp

times

inline operator fun Double.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Double.times(other: IntPx): IntPx

Multiply an IntPx by a Double and round the result to an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Double.times(other: Px): Px

times

inline operator fun Double.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Double.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

times

inline operator fun Float.times(other: Dp): Dp

times

inline operator fun Float.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Float.times(other: IntPx): IntPx

Multiply an IntPx by a Float and round the result to an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Float.times(other: Px): Px

times

inline operator fun Float.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Float.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

times

inline operator fun Int.times(other: Dp): Dp

times

inline operator fun Int.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Int.times(other: IntPx): IntPx

Multiply an IntPx by a Double to result in an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Int.times(size: IntPxSize): IntPxSize

Returns an IntPxSize with size's IntPxSize.width and IntPxSize.height multiplied by this

times

inline operator fun Int.times(other: Px): Px

times

inline operator fun Int.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Int.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

toBounds

fun Size.toBounds(): Bounds

Convert a Size to a Bounds.

toBounds

fun PxSize.toBounds(): PxBounds

Convert a PxSize to a PxBounds. The left and top are 0.px and the right and bottom are the width and height, respectively.

toFrameworkRect

fun Rect.toFrameworkRect(): Rect

toFrameworkRectF

fun Rect.toFrameworkRectF(): RectF

toOffset

inline fun PxPosition.toOffset(): Offset

Convert a PxPosition to a Offset.

toPx

inline fun IntPx.toPx(): Px

toPxPosition

inline fun IntPxPosition.toPxPosition(): PxPosition

Convert a IntPxPosition to a PxPosition

toPxSize

inline fun IntPxSize.toPxSize(): PxSize

Convert a IntPxSize to a PxSize

toRect

fun PxSize.toRect(): Rect

Convert a PxSize to a Rect.

toRect

fun PxBounds.toRect(): Rect

Convert a PxBounds to a Rect.

toSize

fun PxBounds.toSize(): PxSize

Convert a PxBounds to a PxSize.

toSize

inline fun Bounds.toSize(): Size

Convert a Bounds to a Size.

toSize

inline fun IntPxBounds.toSize(): IntPxSize

Convert a IntPxBounds to a IntPxSize.

visitLayoutChildren

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

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

withTight

fun Constraints.withTight(
    width: IntPx? = null,
    height: IntPx? = null
): Constraints

Returns a copy of the current instance, overriding the specified values to be tight.

Extension properties

days

val Int.days: Duration

days

val Long.days: Duration

dp

inline val Double.dp: Dp

Create a Dp using a Double: val left = 10.0 val x = left.dp // -- or -- val y = 10.0.dp

dp

inline val Float.dp: Dp

Create a Dp using a Float: val left = 10f val x = left.dp // -- or -- val y = 10f.dp

dp

inline val Int.dp: Dp

Create a Dp using an Int: val left = 10 val x = left.dp // -- or -- val y = 10.dp

em

val Double.em: TextUnit

Creates an EM unit TextUnit

em

val Float.em: TextUnit

Creates an EM unit TextUnit

em

val Int.em: TextUnit

Creates an EM unit TextUnit

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

hasTightHeight

val Constraints.hasTightHeight: Boolean

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

hasTightWidth

val Constraints.hasTightWidth: Boolean

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

height

inline val Bounds.height: Dp

A height of this Bounds in Dp.

height

inline val IntPxBounds.height: IntPx

A height of this IntPxBounds in IntPx.

height

inline val PxBounds.height: Px

A height of this PxBounds in Px.

hours

val Int.hours: Duration

hours

val Long.hours: Duration

ipx

inline val Int.ipx: IntPx

Create a IntPx using an Int: val left = 10 val x = left.ipx // -- or -- val y = 10.ipx

isTight

val Constraints.isTight: Boolean

Whether there is exactly one size that satisfies the constraints.

isZero

val Constraints.isZero: Boolean

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

microseconds

val Int.microseconds: Duration

microseconds

val Long.microseconds: Duration

milliseconds

val Int.milliseconds: Duration

milliseconds

val Long.milliseconds: Duration

minDimension

val PxSize.minDimension: Px

Returns the smallest dimension size.

minutes

val Int.minutes: Duration

minutes

val Long.minutes: Duration

nanoseconds

val Int.nanoseconds: Duration

nanoseconds

val Long.nanoseconds: Duration

positionInRoot

inline val LayoutCoordinates.positionInRoot: PxPosition

The position of this layout inside the root composable.

px

inline val Double.px: Px

Create a Px using a Double: val left = 10.0 val x = left.px // -- or -- val y = 10.0.px

px

inline val Float.px: Px

Create a Px using a Float: val left = 10f val x = left.px // -- or -- val y = 10f.px

px

inline val Int.px: Px

Create a Px using an Int: val left = 10 val x = left.px // -- or -- val y = 10.px

seconds

val Int.seconds: Duration

seconds

val Long.seconds: Duration

sp

val Double.sp: TextUnit

Creates a SP unit TextUnit

sp

val Float.sp: TextUnit

Creates a SP unit TextUnit

sp

val Int.sp: TextUnit

Creates a SP unit TextUnit

width

inline val Bounds.width: Dp

A width of this Bounds in Dp.

width

inline val IntPxBounds.width: IntPx

A width of this IntPxBounds in IntPx.

width

inline val PxBounds.width: Px

A width of this PxBounds in Px.