[英]How to use androidx.animation.AnimatorSet?
I need to use reverse() method of Android AnimatorSet class.我需要使用 Android AnimatorSet 类的reverse()方法。 The problem is that this method was added only in api 26. But I found reverse method in source code in package androidx.animation.问题是这个方法只在api 26中添加。但我在包androidx.animation的源代码中找到了reverse方法。 And I couldn't find any androidx library that allows to use that AnimatorSet (androidx.animation.AnimatorSet).而且我找不到任何允许使用该 AnimatorSet (androidx.animation.AnimatorSet) 的 androidx 库。 How can I use that class?我怎样才能使用那个类?
For Api >=26
you just create an AnimatorSet
object and after you define the animation you call reverse on it:对于Api >=26
您只需创建一个AnimatorSet
对象,并在定义动画后对其调用 reverse :
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(ObjectAnimator.ofFloat(...), ...);
animatorSet.setDuration(...);
animatorSet.reverse();
animatorSet.start();
For older APIs you just reverse the order within the .ofFloat
methods in your ObjectAnimators
:对于较旧的 API,您只需颠倒.ofFloat
方法中的ObjectAnimators
:
If initially you have ObjectAnimator.ofFloat(0, 1)
you change it to animator.setFloatValues(1, 0)
如果最初你有ObjectAnimator.ofFloat(0, 1)
你把它改成animator.setFloatValues(1, 0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.