The previous blog explains the animtion of Android's simple animation, which explains some of the animations added after Android 3.0 . Animator in the Objectanimator.
1.alpha
The first parameter is the View object, the second argument is the type of the animation change, and the fourth parameter, in turn, starts the transparency and ends the transparency. Objectanimator alpha = objectanimator.offloat (text, "Alpha", 0f, 1f); Alpha.setduration (2000);// Set the animation time Alpha.setinterpolator (new Decelerateinterpolator ());//Set the animation plug, slow down Alpha.setrepeatcount (-1);//Set the animation repetition times, Here-1 stands for Infinity Alpha.setrepeatmode (animation.reverse);//Set animation loop mode. Alpha.start ();//Start animation.
2.scale
Animatorset animatorset = new Animatorset ();//Combo animation Objectanimator ScaleX = objectanimator.offloat (text, "ScaleX", 1f, 0f) ; Objectanimator ScaleY = objectanimator.offloat (text, "ScaleY", 1f, 0f); Animatorset.setduration (2000); Animatorset.setinterpolator (New Decelerateinterpolator ()); Animatorset.play (ScaleX). with (ScaleY);// Two animations start Animatorset.start at the same time ();
3.translate
Objectanimator translationup = objectanimator.offloat (Button, "Y", Button.gety (), 0); Translationup.setinterpolator ( New Decelerateinterpolator ()); Translationup.setduration (); Translationup.start ();
4. Rotate
Animatorset set = new Animatorset (); Objectanimator anim = Objectanimator offloat (phone, "RotationX", 0f, 180f); Anim.setduration (+); Objectanimator anim2 = Objectanimator offloat (phone, "RotationX", 180f, 0f); Anim2.setduration (+); Objectanimator anim3 = Objectanimator offloat (phone, "RotationY", 0f, 180f); Anim3.setduration (+); Objectanimator anim4 = Objectanimator offloat (phone, "RotationY", 180f, 0f); Anim4.setduration (+); Set.play (Anim). before (ANIM2); Executes the Anim animation first after performing the anim2 set.play (ANIM3). before (ANIM4);
5.android change the background color animation is implemented as follows
Objectanimator translationup = objectanimator.ofint (Button, "BackgroundColor", Color.Red, Color.Blue, Color.GRAY, Color.green); Translationup.setinterpolator (new Decelerateinterpolator ()); translationup.setduration (1500); Translationup.setrepeatcount ( -1); Translationup.setrepeatmode (animation.reverse);/* * Argbevaluator: This evaluator can be used to perform interpolation between types of integer values that represent ARGB colors. * Floatevaluator: This evaluator can be used to perform interpolation between floating-point values. * Intevaluator: This evaluator can be used to perform interpolation between type int values. * Rectevaluator: This evaluator can be used to perform interpolation between types of rectangular values. * * Because this example is changing the background color of the view's BackgroundColor property, the Argbevaluator */translationup.setevaluator (New Argbevaluator ()) is used here; Translationup.start ();
Objectanimator of Android Properties animation