我在屏幕的一个角落有一个带有图像的屏幕,我想将它动画到屏幕的中心。
有点像从
Icon(
painter = //,
contentDescription = //,
modifier = Modifier.size(36.dp)
)
至Icon(
painter = //,
contentDescription = //,
modifier = Modifier.fillMaxSize()
)
第一个位于屏幕的左上角,第二个位于屏幕中央。如何在两种状态之间设置动画?
最佳答案
试试这个:
@Composable
fun DUM_E_MARK_II(triggered: Boolean) {
BoxWithConstraints {
val size by animateDpAsState(if (triggered) 36.dp else maxHeight)
Icon(
imageVector = Icons.Filled.Warning,
contentDescription = "Just a better solution to the problem",
modifier = Modifier.size(size)
)
}
}
关于android - 如何在 Jetpack Compose 中实现平移 + 缩放动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69758903/