SHOW:
|
|
- or go back to the newest paste.
1 | objAnimator = ObjectAnimator.ofFloat(elements[2], "translationX", elements[2].getTranslationX() + lateralDistance); | |
2 | //The same as ObjectAnimator.ofFloat(elements[2], "translationX", elements[2].getTranslationX(), elements[2].getTranslationX() + lateralDistance) | |
3 | objAnimator.setDuration(DURATION); | |
4 | ||
5 | objAnimatorTwo = ObjectAnimator.ofFloat(elements[1], "translationX", elements[1].getTranslationX() + lateralDistance); | |
6 | objAnimatorTwo.setDuration(DURATION); | |
7 | ||
8 | PropertyValuesHolder xHolder = PropertyValuesHolder.ofFloat("translationX", elements[3].getTranslationX() - lateralDistance * 2); | |
9 | PropertyValuesHolder yHolder = PropertyValuesHolder.ofFloat("translationY", 0, 1); | |
10 | yHolder.setEvaluator(new FloatEvaluator() { | |
11 | @Override | |
12 | public Float evaluate(float fraction, Number startValue, Number endValue) { | |
13 | float value = super.evaluate(fraction, startValue, endValue); | |
14 | return (float)(-100 * Math.sin(value * Math.PI)); | |
15 | } | |
16 | }); | |
17 | objAnimatorThree = ObjectAnimator.ofFloat(elements[3], xHolder, yHolder); | |
18 | - | // The way you did might be better here |
18 | + | // The way you did with ValueAnimator might be better here |
19 | objAnimatorThree.setDuration(DURATION * 2); | |
20 | ||
21 | animatorSet = new AnimatorSet(); | |
22 | animatorSet.play(objAnimator).with(objAnimatorThree) | |
23 | .before(objAnimatorTwo); | |
24 | animatorSet.addListener(new AnimatorListenerAdapter() { | |
25 | @Override | |
26 | public void onAnimationEnd(Animator animation) { | |
27 | presetElementArray(); | |
28 | animatorSet.start(); | |
29 | } | |
30 | }); |