gpt4 book ai didi

android - 如何使用 Jetpack Compose 创建动画?

转载 作者:行者123 更新时间:2023-12-04 15:38:49 25 4
gpt4 key购买 nike

我想在此代码实验室中使用 Compose 而不是 ConstraintLayout:https://codelabs.developers.google.com/codelabs/advanced-android-kotlin-training-property-animation/#1

如何将任何动画应用于 Compose?

最佳答案

从 beta08 开始,现在更容易了

@Composable
fun RotateLoader() {
val animation = rememberInfiniteTransition()
val angle = animation.animateFloat(
initialValue = 0f,
targetValue = 360f,
animationSpec = infiniteRepeatable(
animation = tween(
durationMillis = 1000,
easing = LinearEasing
),
repeatMode = RepeatMode.Restart
)
)
Icon(
painter = painterResource(id = R.drawable.ic_loader),
contentDescription = null,
modifier = Modifier.rotate(angle.value)
)
}

关于android - 如何使用 Jetpack Compose 创建动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58776590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com