Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,15 @@ private fun AnimateAsStateSimple() {
// [START android_compose_animations_animate_as_state]
var enabled by remember { mutableStateOf(true) }

val alpha: Float by animateFloatAsState(if (enabled) 1f else 0.5f, label = "alpha")
val animatedAlpha: Float by animateFloatAsState(if (enabled) 1f else 0.5f, label = "alpha")
Box(
Modifier
.fillMaxSize()
.graphicsLayer(alpha = alpha)
.graphicsLayer { alpha = animatedAlpha }
.background(Color.Red)
)
// [END android_compose_animations_animate_as_state]
{ Button(onClick = { enabled = !enabled }) { Text("Animate me!") } }
}

@Preview
Expand Down