Skip to content

Use AnimatorSet to chain animations

rutura edited this page Apr 16, 2017 · 1 revision
  • Chaining animations in Java Code is verbose so we do that in xml
  • Put your animation xml files in the res/animator folder
  • Inflate your animation xml file
  • Set a target to your animation like this: mFlipper.setTarget(mFlipImage);// In App1.4.2 , ObjectAnimator.ofFloat() did this for us implicitly
  • Add an update listener to the correct ObjectAnimator //The animations are probably stored in some kind of container and you //retrieve them in the order they are stored in inside the flip.xml //animation file.
         ObjectAnimator flipAnimator = (ObjectAnimator) mFlipper.getChildAnimations().get(0);
         flipAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {...}
Clone this wiki locally