gpt4 book ai didi

android - 动画后将 View 重置为原始位置

转载 作者:太空狗 更新时间:2023-10-29 16:10:43 27 4
gpt4 key购买 nike

我正在为 View 设置动画,我想在动画结束后将 View 重置为原始位置。

这是我的:

rl2 是一个相对布局

rl2.animate().translationX(-60).translationY(117).setDuration(2000);

我尝试设置它但它不起作用:

rl2.clearAnimation();

最佳答案

clearAnimation(); 不会重置您的动画,它只是停止它们并将它们从动画队列中移除。要撤消动画,您需要实际撤消它们。因此,对于您的代码块,您需要调用 rl2.animate().translationX(0).translationY(0).setDuration(2000); 将 View 移回其原始位置。

关于android - 动画后将 View 重置为原始位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53214586/

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