private void animTo (View v, float toX, float toY, float duration) {
If (duration & lt; 0 {
return;
}
ObjectAnimator animX=ObjectAnimator. OfFloat (v, "x", toX);
ObjectAnimator animY=ObjectAnimator. OfFloat (v, "y", toY);
AnimatorSet animSet=new AnimatorSet ();
AnimSet. Play (animX) with (animY);
AnimSet. SetDuration ((long) duration);
AnimSet. Start ();
}
Call:
animTo (lytCool lytCoolEndX, lytCoolEndY, lytCoolDuration);
Error:
03-01 14:20:30. 709 E/AndroidRuntime (2208) : FATAL EXCEPTION: the main
03-01 14:20:30. 709 E/AndroidRuntime (2208) : the Process: com. Meross. Meross, PID: 2208
03-01 14:20:30. 709 E/AndroidRuntime (2208) : Java. Lang. UnsupportedOperationException: Sorting went bad, the start event should always be at index 0
03-01 14:20:30. 709 E/AndroidRuntime (2208) : an android. The animation. The AnimatorSet. SortAnimationEvents AnimatorSet. Java: (1631)
03-01 14:20:30. 709 E/AndroidRuntime (2208) : an android. The animation. The AnimatorSet. CreateDependencyGraph AnimatorSet. Java: (1527)
03-01 14:20:30. 709 E/AndroidRuntime (2208) : an android. The animation. The AnimatorSet. InitAnimation AnimatorSet. Java: (700)
03-01 14:20:30. 709 E/AndroidRuntime (2208) : an android. The animation. The AnimatorSet. Start (AnimatorSet. Java: 719)
03-01 14:20:30. 709 E/AndroidRuntime (2208) : an android. The animation. The AnimatorSet. Start (AnimatorSet. Java: 684)
CodePudding user response:
animTo (View v, float toX, float toY, float duration)v is not null, duration of constant greater than zero