Nineoldandroids Study Notes

Source: Internet
Author: User

There are three ways to animate controls in the Nineoldandroids library.

First:

Proxy_properties.put ("Alpha", Prehoneycombcompat.alpha);
Proxy_properties.put ("Pivotx", prehoneycombcompat.pivot_x);
Proxy_properties.put ("Pivoty", prehoneycombcompat.pivot_y);
Proxy_properties.put ("Translationx", prehoneycombcompat.translation_x);
Proxy_properties.put ("Translationy", prehoneycombcompat.translation_y);
Proxy_properties.put ("Rotation", prehoneycombcompat.rotation);
Proxy_properties.put ("RotationX", prehoneycombcompat.rotation_x);
Proxy_properties.put ("RotationY", prehoneycombcompat.rotation_y);
Proxy_properties.put ("ScaleX", prehoneycombcompat.scale_x);
Proxy_properties.put ("ScaleY", prehoneycombcompat.scale_y);
Proxy_properties.put ("Scrollx", prehoneycombcompat.scroll_x);
Proxy_properties.put ("scrolly", prehoneycombcompat.scroll_y);
Proxy_properties.put ("x", Prehoneycombcompat.x);
Proxy_properties.put ("Y", prehoneycombcompat.y);

Objectanimator.offloat (Target, "Translationx", 0, -50, 0). setduration (Duration). Start ();

Objectanimator.offloat (Target, "Translationy", 0, -50, 0). setduration (Duration). Start ();

Objectanimator.offloat (Target, "ScaleX", 1, 2, 1). Setduration (Duration). Start ();

Objectanimator.offloat (Target, "ScaleY", 1, 2, 1). Setduration (Duration). Start ();

Objectanimator.offloat (target, "Alpha", 1, 0, 1). Setduration (Duration). Start ();

Objectanimator.offloat (Target, "RotationX", 0, 0). setduration (Duration). Start ();

Objectanimator.offloat (Target, "RotationY", 0, 0). setduration (Duration). Start ();

Objectanimator.offloat (target, "rotation", 0, 0). setduration (Duration). Start ();


The following two are custom, to be added in view Setphasex Getphasex,setphasey, Getphasey, Mphasey, mphasex definition;

Objectanimator.offloat (Target, "Phasey", 0f, 1f). Setduration (Durationmillisy). Start ();

Objectanimator.offloat (Target, "Phasex", 0f, 1f). Setduration (DURATIONMILLISX). Start ();

Animatorpath path = new Animatorpath ();
Path.moveto (0, 0);
Path.lineto (0, 300);
Path.curveto (100, 0, 300, 900, 400, 500);
Objectanimator.ofobject (Target, "Buttonloc", New Pathevaluator (), Path.getpoints (). ToArray ()). Setduration (1000). Start ();


////

Objectanimator.offloat (Target, "Translationx", 0, -50, 0). setduration (Duration). Start ();
Objectanimator.offloat (Target, "Translationy", 0, -50, 0). setduration (Duration). Start ();

Objectanimator.offloat (Target, "ScaleX", 1, 2, 1). Setduration (Duration). Start ();
Objectanimator.offloat (Target, "ScaleY", 1, 2, 1). Setduration (Duration). Start ();

Objectanimator.offloat (target, "Alpha", 1, 0, 1). Setduration (Duration). Start ();

//=======
Objectanimator.offloat (Target, "RotationX", 0, 0). setduration (Duration). Start (); X-Axis Rotation
Objectanimator.offloat (Target, "RotationY", 0, 0). setduration (Duration). Start (); Y-Axis rotation
Objectanimator.offloat (target, "rotation", 0, 0). setduration (Duration). Start (); Z-axis Rotation
Set Rotation center point (0,0)
Viewhelper.setpivotx (target, 0);
Viewhelper.setpivoty (target, 0);
//Set Rotation center point (WIDTH/2,HEIGHT/2)
Viewhelper.setpivotx (Target, target.getwidth ()/2f);
Viewhelper.setpivoty (Target, target.getheight ()/2f);
//Set Rotation center point (width,height)
Viewhelper.setpivotx (Target, Target.getwidth ());
Viewhelper.setpivoty (Target, Target.getheight ());

//=======


Second:

Animate (target). Setduration (+). Alpha (0);

Animate (target). Setduration (+) . Alpha (1);

Animate (target). Setduration (+) .. X (xValue). Y (yvalue);

Animate (target). Setduration (+) .. X (0). Y (0);

Animate (target). Setduration (+) . Rotationyby (720);

Third:

Valueanimator Coloranim = Objectanimator.ofint (This, "BackgroundColor", RED, BLUE);
Coloranim.setduration (3000);
Coloranim.setevaluator (New Argbevaluator ());
Coloranim.setrepeatcount (Valueanimator.infinite);
Coloranim.setrepeatmode (Valueanimator.reverse);
Coloranim.start ();

Valueanimator Bounceanim = objectanimator.offloat (Newball, "Y", Starty, EndY);
Bounceanim.setduration (duration);
Bounceanim.setinterpolator (New Accelerateinterpolator ());

Valueanimator squashAnim1 = objectanimator.offloat (Newball, "X", Newball.getx (), Newball.getx ()-25f);
Squashanim1.setduration (DURATION/4);
Squashanim1.setrepeatcount (1);
Squashanim1.setrepeatmode (Valueanimator.reverse);
Squashanim1.setinterpolator (New Decelerateinterpolator ());

Valueanimator squashAnim2 = objectanimator.offloat (Newball, "width", newball.getwidth (), newball.getwidth () + 50);
Squashanim2.setduration (DURATION/4);
Squashanim2.setrepeatcount (1);
Squashanim2.setrepeatmode (Valueanimator.reverse);
Squashanim2.setinterpolator (New Decelerateinterpolator ());

Valueanimator stretchAnim1 = objectanimator.offloat (Newball, "Y", EndY, EndY + 25f);
Stretchanim1.setduration (DURATION/4);
Stretchanim1.setrepeatcount (1);
Stretchanim1.setinterpolator (New Decelerateinterpolator ());
Stretchanim1.setrepeatmode (Valueanimator.reverse);

Valueanimator stretchAnim2 = objectanimator.offloat (Newball, "height", newball.getheight (), Newball.getheight ()-25);
Stretchanim2.setduration (DURATION/4);
Stretchanim2.setrepeatcount (1);
Stretchanim2.setinterpolator (New Decelerateinterpolator ());
Stretchanim2.setrepeatmode (Valueanimator.reverse);

Valueanimator Bouncebackanim = objectanimator.offloat (Newball, "Y", EndY, Starty);
Bouncebackanim.setduration (duration);
Bouncebackanim.setinterpolator (New Decelerateinterpolator ());

Sequence the Down/squash&stretch/up animations
Animatorset bouncer = new Animatorset ();
Bouncer.play (Bounceanim). before (SQUASHANIM1);
Bouncer.play (SQUASHANIM1). with (SQUASHANIM2);
Bouncer.play (SQUASHANIM1). with (STRETCHANIM1);
Bouncer.play (SQUASHANIM1). with (STRETCHANIM2);
Bouncer.play (Bouncebackanim). After (STRETCHANIM2);

Fading Animation-remove the ball when the animation was done
Valueanimator Fadeanim = objectanimator.offloat (Newball, "Alpha", 1f, 0f);
Fadeanim.setduration (250);
Fadeanim.addlistener (New Animatorlisteneradapter () {
@Override
public void Onanimationend (Animator animation) {
Balls.remove (((objectanimator) animation). Gettarget ());


}
});

Sequence the animations to play one after the other
Animatorset animatorset = new Animatorset ();
Animatorset.play (Bouncer). before (Fadeanim);

Start the animation
Animatorset.start ();

Nineoldandroids Study Notes

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.