WhaleJesus
Lurker
Code:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var sizeState by remember { mutableStateOf(200.dp) }
val size by animateDpAsState(
targetValue = sizeState,
keyframes {
durationMillis = 5000
sizeState at 0 with LinearEasing
sizeState * 1.5f at 1000
sizeState * 2f at 5000
}
Box(modifier = Modifier
.size(size)
.background(Color.Red),
contentAlignment = Alignment.Center) {
Button(onClick = {
sizeState += 50.dp
}) {
Text("Increase Size")
}
}
}
}
}
Last edited: