Original URL: http://blog.csdn.net/feiduclear_up/article/details/39255083
The previous blog explains the animtion of the Android simple animation, which explains some of the objectanimator in the animated animator that were added after Android 3.0.
Property Animation concept: The so-called property animation: Change the property values of all the objects that can be changed, unlike tweened animations: You can only change alpha,scale,rotate,translate. Listen a little bit abstract, give an example of the motion tween can achieve:
1.alpha
[Java]View PlainCopy
- 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 (+); Set animation time
- Alpha.setinterpolator (new Decelerateinterpolator ()); Set the animation plug, decelerate
- Alpha.setrepeatcount (-1); Set the number of animations to repeat, here-1 for Infinity
- Alpha.setrepeatmode (Animation.reverse); //Set animation cycle mode.
- Alpha.start (); //Start animation.
2.scale
[Java]View PlainCopy
- Animatorset Animatorset = new Animatorset (); Combo Animations
- 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 at the same time
- Animatorset.start ();
3.translate
[Java]View PlainCopy
- Objectanimator translationup = objectanimator.offloat (Button, "Y",
- Button.gety (), 0);
- Translationup.setinterpolator (new Decelerateinterpolator ());
- Translationup.setduration (1500);
- Translationup.start ();
4. Rotate
[Java]View PlainCopy
- Animatorset set = new Animatorset ();
- Objectanimator anim = Objectanimator offloat (phone, "RotationX", 0f, 180f);
- Anim.setduration (2000);
- Objectanimator anim2 = Objectanimator offloat (phone, "RotationX", 180f, 0f);
- Anim2.setduration (2000);
- Objectanimator anim3 = Objectanimator offloat (phone, "RotationY", 0f, 180f);
- Anim3.setduration (2000);
- Objectanimator anim4 = Objectanimator offloat (phone, "RotationY", 180f, 0f);
- Anim4.setduration (2000);
- Set.play (Anim). before (ANIM2); //Perform anim animation before executing anim2
- Set.play (ANIM3). before (ANIM4);
- Set.start ();
tweened animations are not possible:
5.android change the background color animation is implemented as follows
[Java]View PlainCopy
- 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, use Argbevaluator here
- */
- Translationup.setevaluator (new Argbevaluator ());
- Translationup.start ();
For more information on Android properties animation, please refer to the Detailed blog Android Properties animation property Animation series one of the Valueanimator
Objectanimator of "Turn" Android property animation