MotionLayoutScope
@ExperimentalMotionApi
@LayoutScopeMarker
class MotionLayoutScope
Summary
Nested types |
|---|
inner class MotionLayoutScope.CustomProperties |
inner class MotionLayoutScope.MotionProperties |
Public functions |
|
|---|---|
Color |
customColor(id: String, name: String)Return the current |
Dp |
customDistance(id: String, name: String)Return the current |
Float |
customFloat(id: String, name: String)Return the current |
TextUnit |
customFontSize(id: String, name: String)Return the current |
Int |
Return the current |
MotionLayoutScope.CustomProperties |
customProperties(id: String)Returns a |
Color |
This function is deprecated. Deprecated for naming consistency |
Dp |
This function is deprecated. Deprecated for naming consistency |
Float |
This function is deprecated. Deprecated for naming consistency |
TextUnit |
This function is deprecated. Deprecated for naming consistency |
Int |
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(Invokes |
Public functions
customColor
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
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
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
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
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
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.
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.