我是喷气背包作曲的新手.我想就一项任务征求一些建议.任务包括
任务步骤包括
- 在动画中按比例显示应用程序徽标
- 徽标应随横向扩展动画一起消失
- 一旦徽标消失,登录屏幕应按动画中的比例出现
我想获得这个棘手的安卓动画.我寻找交叉淡入淡出和动画内容,但问题是,我没有办法发现,徽标是从进入退出过渡扩展,所以在标识扩展后,然后只有我想要的登录屏幕来扩展. 如果有人能为实现这一目标提出建议的话. 先谢谢你
我是喷气背包作曲的新手.我想就一项任务征求一些建议.任务包括
任务步骤包括
我想获得这个棘手的安卓动画.我寻找交叉淡入淡出和动画内容,但问题是,我没有办法发现,徽标是从进入退出过渡扩展,所以在标识扩展后,然后只有我想要的登录屏幕来扩展. 如果有人能为实现这一目标提出建议的话. 先谢谢你
你能更详细地解释一下这项任务吗?最好是一步一步地为所需的动画算法. 我会编辑此消息,如果我可以帮助,或更多的细节,从你会帮助其他受访者.
更新
是像这样吗?
更新 2
按比例设置内容动画的功能:
@Composable
private fun ScaleAnimatedVisibility(
visible: Boolean,
scalePosition: (scale: Float) -> Unit,
animationDurationMillis: Int,
delayScaleInAnimation: Int = 0,
delayScaleOutAnimation: Int = 0,
content: @Composable () -> Unit
) {
val scale by animateFloatAsState(
targetValue = if (visible) 1f else 0f,
animationSpec = tween(
delayMillis = if (visible) delayScaleInAnimation else delayScaleOutAnimation,
durationMillis = animationDurationMillis
),
label = ""
)
Box(
modifier = Modifier.scale(scale = scale)
) {
scalePosition(scale)
content()
}
}
使用示例:
@Composable
fun AnimatedScreenAndLogo() {
var animationIsPlaying by remember { mutableStateOf(false) }
var animateLogo by remember { mutableStateOf(false) }
var animateLoginScreen by remember { mutableStateOf(false) }
Box(
modifier = Modifier
.fillMaxSize()
.background(color = Color.White),
contentAlignment = Alignment.Center
) {
ScaleAnimatedVisibility(
visible = animateLogo,
scalePosition = { scale ->
if (animateLogo && animationIsPlaying && scale == 1f) {
animateLogo = false
} else {
if (!animateLogo && animationIsPlaying && scale == 0f) {
animateLoginScreen = true
}
}
},
delayScaleOutAnimation = 1000,
animationDurationMillis = 1000
) {
Logo()
}
ScaleAnimatedVisibility(
visible = animateLoginScreen,
scalePosition = {},
animationDurationMillis = 1000,
delayScaleInAnimation = 1000,
) {
LoginScreen()
}
}
LaunchedEffect(key1 = Unit, block = {
animationIsPlaying = true
animateLogo = true
})
}