androidx.ui.animation

Classes

ColorPropKey

Built-in property key for Color properties.

DpPropKey

Built-in property key for Dp properties.

PxPositionPropKey

Built-in property key for PxPosition properties.

PxPropKey

Built-in property key for Px properties.

Top-level functions summary

Unit
Crossfade(current: T, children: (T) -> Unit)

Crossfade allows to switch between two layouts with a crossfade animation.

Unit
Transition(definition: TransitionDefinition<T>, toState: T, clock: AnimationClockObservable = +ambient(AnimationClockAmbient), onStateChangeFinished: (T) -> Unit = null, children: (state: TransitionState) -> Unit)

Composable to use with TransitionDefinition-based animations.

Effect<AnimatedValue<Color>>
animatedColor(initVal: Color)

The animatedValue effect creates an AnimatedValue of Color and positionally memoizes it.

Effect<AnimatedFloat>
animatedFloat(initVal: Float)

The animatedValue effect creates an AnimatedFloat and positionally memoizes it.

Effect<AnimatedValue<T>>
animatedValue(initVal: T, interpolator: (T, T, Float) -> T)

The animatedValue effect creates an AnimatedValue and positionally memoizes it.

Top-level properties summary

Boolean

Stores the enabled state for Transition animations.

Top-level functions

Crossfade

@Composable fun <T> Crossfade(
    current: T,
    children: (T) -> Unit
): Unit

Crossfade allows to switch between two layouts with a crossfade animation.

import androidx.ui.animation.Crossfade
import androidx.ui.core.Text

Crossfade(current = "A") { screen ->
    when (screen) {
        "A" -> Text("Page A")
        "B" -> Text("Page B")
    }
}
Parameters
current: T is a key representing your current layout state. every time you change a key the animation will be triggered. The children called with the old key will be faded out while the children called with the new key will be faded in.

Transition

@Composable fun <T> Transition(
    definition: TransitionDefinition<T>,
    toState: T,
    clock: AnimationClockObservable = +ambient(AnimationClockAmbient),
    onStateChangeFinished: (T) -> Unit = null,
    children: (state: TransitionState) -> Unit
): Unit

Composable to use with TransitionDefinition-based animations.

import androidx.animation.transitionDefinition
import androidx.ui.animation.ColorPropKey
import androidx.ui.animation.Transition
import androidx.ui.foundation.ColoredRect

val ColorKey = ColorPropKey()
val definition = transitionDefinition {
    state(State.First) {
        this[ColorKey] = Color.Red
    }
    state(State.Second) {
        this[ColorKey] = Color.Green
    }
}

@Composable
fun TransitionBasedColoredRect() {
    Transition(definition = definition, toState = State.Second) { state ->
        ColoredRect(color = state[ColorKey])
    }
}

animatedColor

@CheckResult("+") fun animatedColor(initVal: Color): Effect<AnimatedValue<Color>>

The animatedValue effect creates an AnimatedValue of Color and positionally memoizes it. When the AnimatedValue object gets its value updated, components that rely on that value will be automatically recomposed.

Parameters
initVal: Color Initial value to set AnimatedValue to.

animatedFloat

@CheckResult("+") fun animatedFloat(initVal: Float): Effect<AnimatedFloat>

The animatedValue effect creates an AnimatedFloat and positionally memoizes it. When the AnimatedFloat object gets its value updated, components that rely on that value will be automatically recomposed.

Parameters
initVal: Float Initial value to set AnimatedFloat to.

animatedValue

@CheckResult("+") fun <T> animatedValue(
    initVal: T,
    interpolator: (T, T, Float) -> T
): Effect<AnimatedValue<T>>

The animatedValue effect creates an AnimatedValue and positionally memoizes it. When the AnimatedValue object gets its value updated, components that rely on that value will be automatically recomposed.

Parameters
initVal: T Initial value to set AnimatedValue to.
interpolator: (T, T, Float) -> T A value interpolator for interpolating two values of type T

Top-level properties

transitionsEnabled

var transitionsEnabled: Boolean

Stores the enabled state for Transition animations. Useful for tests to disable animations and have reliable screenshot tests.