gpt4 book ai didi

android - 如何在 compose 中控制 AnimatedVisibility 的方向?

转载 作者:行者123 更新时间:2023-12-05 04:23:57 25 4
gpt4 key购买 nike

我用过 compose AnimatedVisibility在我的项目中,我想为 slideInVertically() 更改 AnimatedVisibility 的方向从下到上和slideOutVertically()从上到下。如何做到这一点?

 AnimatedVisibility(
visible = state.value,
enter = slideInVertically(),
exit = slideOutVertically())
{

// ...

}

最佳答案

像这样使用initialOffsetYtargetOffsetY来改变动画方向。

enter = slideInVertically(
initialOffsetY = {
it / 2
},
),
exit = slideOutVertically(
targetOffsetY = {
it / 2
},
),

来源: EnterExitTransition.kt源码

This slides in the content vertically, from a starting offset defined in initialOffsetY to 0 in pixels. The direction of the slide can be controlled by configuring the initialOffsetY. A positive initial offset means sliding up, whereas a negative value would slide the content down.

This slides out the content vertically, from 0 to a target offset defined in targetOffsetY in pixels. The direction of the slide-out can be controlled by configuring the targetOffsetY. A positive target offset means sliding down, whereas a negative value would slide the content up.

关于android - 如何在 compose 中控制 AnimatedVisibility 的方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73599809/

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