@ExperimentalMotionApi
@LayoutScopeMarker
class MotionLayoutScope


Summary

Public functions

Color
customColor(id: String, name: String)

Return the current Color value of the custom property name, of the id layout.

Dp

Return the current Dp value of the custom property name, of the id layout.

Float
customFloat(id: String, name: String)

Return the current Color value of the custom property name, of the id layout.

TextUnit

Return the current TextUnit value of the custom property name, of the id layout.

Int
customInt(id: String, name: String)

Return the current Int value of the custom property name, of the id layout.

MotionLayoutScope.CustomProperties

Returns a CustomProperties instance to access the values of custom properties defined for id in different return types: Color, Float, Int, Dp, TextUnit.

Color
motionColor(id: String, name: String)

This function is deprecated. Deprecated for naming consistency

Dp

This function is deprecated. Deprecated for naming consistency

Float
motionFloat(id: String, name: String)

This function is deprecated. Deprecated for naming consistency

TextUnit

This function is deprecated. Deprecated for naming consistency

Int
motionInt(id: String, name: String)

This function is deprecated. Deprecated for naming consistency

State<MotionLayoutScope.MotionProperties>

This function is deprecated. Unnecessary composable, name is also inconsistent for custom properties

MotionLayoutScope.MotionProperties

This function is deprecated. Deprecated for naming consistency

Modifier
Modifier.onStartEndBoundsChanged(
    layoutId: Any,
    onBoundsChanged: (startBounds: Rect, endBounds: Rect) -> Unit
)

Invokes onBoundsChanged whenever the Start or End bounds may have changed for the Composable corresponding to the given layoutId during positioning.

Public functions

customColor

Added in 1.1.0
fun customColor(id: String, name: String): Color

Return the current Color value of the custom property name, of the id layout.

Returns Color.Unspecified if the property does not exist.

This is a short version of: customProperties(id).color(name).

customDistance

Added in 1.1.0
fun customDistance(id: String, name: String): Dp

Return the current Dp value of the custom property name, of the id layout.

Returns Dp.Unspecified if the property does not exist.

This is a short version of: customProperties(id).distance(name).

customFloat

Added in 1.1.0
fun customFloat(id: String, name: String): Float

Return the current Color value of the custom property name, of the id layout.

Returns Color.Unspecified if the property does not exist.

This is a short version of: customProperties(id).float(name).

customFontSize

Added in 1.1.0
fun customFontSize(id: String, name: String): TextUnit

Return the current TextUnit value of the custom property name, of the id layout.

Returns TextUnit.Unspecified if the property does not exist.

This is a short version of: customProperties(id).fontSize(name).

customInt

Added in 1.1.0
fun customInt(id: String, name: String): Int

Return the current Int value of the custom property name, of the id layout.

Returns 0 if the property does not exist.

This is a short version of: customProperties(id).int(name).

customProperties

Added in 1.1.0
fun customProperties(id: String): MotionLayoutScope.CustomProperties

Returns a CustomProperties instance to access the values of custom properties defined for id in different return types: Color, Float, Int, Dp, TextUnit.

Note that there are no type guarantees when setting or getting custom properties, so be mindful of the value type used for it in the MotionScene.

motionColor

Added in 1.1.0
Deprecated in 1.1.0
fun motionColor(id: String, name: String): Color

motionDistance

Added in 1.1.0
Deprecated in 1.1.0
fun motionDistance(id: String, name: String): Dp

motionFloat

Added in 1.1.0
Deprecated in 1.1.0
fun motionFloat(id: String, name: String): Float

motionFontSize

Added in 1.1.0
Deprecated in 1.1.0
fun motionFontSize(id: String, name: String): TextUnit

motionInt

Added in 1.1.0
Deprecated in 1.1.0
fun motionInt(id: String, name: String): Int

motionProperties

Added in 1.1.0
Deprecated in 1.1.0
@Composable
fun motionProperties(id: String): State<MotionLayoutScope.MotionProperties>

motionProperties

Added in 1.1.0
Deprecated in 1.1.0
fun motionProperties(id: String, tag: String): MotionLayoutScope.MotionProperties

onStartEndBoundsChanged

fun Modifier.onStartEndBoundsChanged(
    layoutId: Any,
    onBoundsChanged: (startBounds: Rect, endBounds: Rect) -> Unit
): Modifier

Invokes onBoundsChanged whenever the Start or End bounds may have changed for the Composable corresponding to the given layoutId during positioning. This may happen if the current Transition for MotionLayout changes.

onBoundsChanged will be invoked at least once when the content is placed the first time.

Use this Modifier instead of onGloballyPositioned if you wish to keep track of Composable bounds while ignoring their positioning during animation. Such as when implementing DragAndDrop logic.