Objectanimator of Android Properties animation

Source: Internet
Author: User

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

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.