Objectanimator of "Turn" Android property animation

Source: Internet
Author: User

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 
  1. 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.
  2. Objectanimator alpha = objectanimator.offloat (text, "Alpha", 0f, 1f);
  3. Alpha.setduration (+); Set animation time
  4. Alpha.setinterpolator (new Decelerateinterpolator ()); Set the animation plug, decelerate
  5. Alpha.setrepeatcount (-1); Set the number of animations to repeat, here-1 for Infinity
  6. Alpha.setrepeatmode (Animation.reverse);  //Set animation cycle mode.
  7. Alpha.start ();  //Start animation.


2.scale

[Java]View PlainCopy 
  1. Animatorset Animatorset = new Animatorset (); Combo Animations
  2. Objectanimator ScaleX = objectanimator.offloat (text, "ScaleX", 1f, 0f);
  3. Objectanimator ScaleY = objectanimator.offloat (text, "ScaleY", 1f, 0f);
  4. Animatorset.setduration (2000);
  5. Animatorset.setinterpolator (new Decelerateinterpolator ());
  6. Animatorset.play (ScaleX). with (ScaleY); //Two animations start at the same time
  7. Animatorset.start ();


3.translate

[Java]View PlainCopy 
    1. Objectanimator translationup = objectanimator.offloat (Button, "Y",
    2. Button.gety (), 0);
    3. Translationup.setinterpolator (new Decelerateinterpolator ());
    4. Translationup.setduration (1500);
    5. Translationup.start ();


4. Rotate

[Java]View PlainCopy 
  1. Animatorset set = new Animatorset ();
  2. Objectanimator anim = Objectanimator offloat (phone, "RotationX", 0f, 180f);
  3. Anim.setduration (2000);
  4. Objectanimator anim2 = Objectanimator offloat (phone, "RotationX", 180f, 0f);
  5. Anim2.setduration (2000);
  6. Objectanimator anim3 = Objectanimator offloat (phone, "RotationY", 0f, 180f);
  7. Anim3.setduration (2000);
  8. Objectanimator anim4 = Objectanimator offloat (phone, "RotationY", 180f, 0f);
  9. Anim4.setduration (2000);
  10. Set.play (Anim). before (ANIM2); //Perform anim animation before executing anim2
  11. Set.play (ANIM3). before (ANIM4);
  12. Set.start ();

tweened animations are not possible:

5.android change the background color animation is implemented as follows

[Java]View PlainCopy  
  1. Objectanimator translationup = objectanimator.ofint (Button,
  2. "BackgroundColor", Color.Red, Color.Blue, Color.gray,
  3. Color.green);
  4. Translationup.setinterpolator (new Decelerateinterpolator ());
  5. Translationup.setduration (1500);
  6. Translationup.setrepeatcount (-1);
  7. Translationup.setrepeatmode (Animation.reverse);
  8. /* 
  9. * Argbevaluator: This evaluator can be used to perform interpolation between types of integer values that represent ARGB colors.
  10. * Floatevaluator: This evaluator can be used to perform interpolation between floating-point values.
  11. * Intevaluator: This evaluator can be used to perform interpolation between type int values.
  12. * Rectevaluator: This evaluator can be used to perform interpolation between types of rectangular values.
  13. *
  14. * Because this example is changing the background color of the view's BackgroundColor property, use Argbevaluator here
  15. */
  16. Translationup.setevaluator (new Argbevaluator ());
  17. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.