gpt4 book ai didi

Android 查看动画到顶部父级

转载 作者:行者123 更新时间:2023-11-29 01:18:15 27 4
gpt4 key购买 nike

我的目标是将当前 View 从其当前位置(中心)动画化到其父级的顶部边框。那可能吗?我已经尝试了下一个代码,但问题是我的 View 在动画后消失了:

Animation bottomUp = AnimationUtils.loadAnimation(context, R.anim.bottom_up);
popup.startAnimation(bottomUp);

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%"
android:toYDelta="0%"
android:fillAfter="true"
android:duration="500"/>
</set>

最佳答案

这可以在 Java 中使用 ViewPropertyAnimator 轻松完成。

popup.animate().translationY(0).setDuration(500); // 0 is top of Y axis

动画总是从当前位置开始。

检查 ViewPropertyAnimator future 动画的文档,它非常易于使用,可以为您节省大量代码。

关于Android 查看动画到顶部父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38391866/

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