本文介绍了使用单个ObjectAnimator更改多个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常复杂的动画,我需要编写代码,并且正在使用一堆ObjectAnimator,如下所示:
I have a pretty complex animation I need to code and I'm using a bunch of ObjectAnimators like the following:
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view, TRANSLATION_X, value).setDuration(BASE_DURATION * 2);
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, TRANSLATION_Y, value).setDuration(BASE_DURATION * 2);
是否可以将X和Y转换分组到同一个ObjectAnimator中,而不是创建一堆然后将它们全部添加到AnimatorSet中?
Is it possible to group the X and Y translations into the same ObjectAnimator rather than creating a bunch of them then adding them all into an AnimatorSet?
谢谢!
推荐答案
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(TRANSLATION_X, value);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, value);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(view, pvhX, pvhY);
animator.setDuration(BASE_DURATION * 2);
animator.start();
http://developer.android.com/guide/topic/graphics/prop-animation.html#views 一个ObjectAnimator
http://developer.android.com/guide/topics/graphics/prop-animation.html#views One ObjectAnimator
这篇关于使用单个ObjectAnimator更改多个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!