gpt4 book ai didi

android - 指定 ViewPropertyAnimator 的起始值

转载 作者:太空宇宙 更新时间:2023-11-03 13:29:53 25 4
gpt4 key购买 nike

使用 ObjectAnimator,可选地使用 PropertyValuesHolder,可以指定动画属性的起始值和结束值:

ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 20f, 50f);
ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 30f, 100f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();

PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 20f, 50f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 30f, 100f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start();

如何使用 ViewPropertyAnimator 实现相同的动画效果?语法似乎不支持起始值,假设它们等于 View 在动画开始时的值:

myView.animate().x(50f).y(100f); //Where do I put starting values??

谢谢;)

最佳答案

如果您要使用 ViewPropertyAnimator,您的 View 需要在动画开始前位于起始位置。

关于android - 指定 ViewPropertyAnimator 的起始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14660250/

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