Android Animation use

Source: Internet
Author: User

Android animation is basically divided into two times, one is 3.0 (API14) before the animation animation, a 3.0 after the animator animation.

Animation AnimationViewGroup when drawing the view of the current animation to play, first to get the animation transformation value of the view by ViewGroup's Drawchild function, Then call the Canvas.concat method, complete the animation through the matrix operation and the Invalidate method, which consumes more CPU resources.

1. Tween AnimationAlpha, scale, Rotate, translation
1. Code AnimationsetAnimated Property Set
2. Layout Animationutil

2. Frame animationPicture polling playback

Animator Animation

With Animatorset and objectanimator mates, finer control with Objectanimator, and automatic actuation, multiple objectanimator combined into animatorset form an animation. Reduce frequent drawing during animation and reduce CPU resource consumption.

Manipulated attribute parameters: X/y;scalex/scaley;rotationx/rotationy;transitionx/transitiony;alpha

1.translationX and Translationy: Controls where the View object starts at the upper-left coordinate of its layout container.
2.rotation, RotationX, and RotationY: Controls the View object to rotate 2D and 3D around the pivot point.
3.scaleX and ScaleY: Controls the 2D scaling of the View object around its pivot point.
The 4.pivotX and Pivoty control the pivot position of the View object, which, by default, is the center point of the View object.
5.x and Y: Describes the final position of the View object in its container, which is the sum of the initial upper-left coordinates and the Translationx and Translationy values.
6.alpha: It represents the alpha transparency of the View object. The default value is 1, and 0 represents full transparency.

Valueanimator---Freefall

Final Valueanimator animator = valueanimator.offloat (0, Screenheight-imageview.getheight ()); Animator.settarget (view ); Animator.setinterpolator (new Bounceinterpolator ()); Animator.setduration (+). Start (); Animator.addupdatelistener (New Animatorupdatelistener () {@Overridepublic void Onanimationupdate (valueanimator Animation) {Float value = (float) animation.getanimatedvalue (); Imageview.settranslationy (value);}});

Or:

Objectanimator animator = Objectanimator.offloat (Mimageview, "Translationy", 100.0f, 0.0f); Animator.setinterpolator ( New Bounceinterpolator ()); animator.setduration (+); Animator.start ();

Objectanimator---transparency and displacement

Objectanimator animator = Objectanimator.offloat (ImageView, "Alpha", 0f, 1.0f); animator.setduration (1000); Animator.start (); Animator.addlistener (new Animatorlisteneradapter () {@Overridepublic void Onanimationend (animator Animation) {Super.onanimationend (animation); Imageview.settranslationy (400);}});
Or:

<objectanimator xmlns:android= "Http://schemas.android.com/apk/res/android" android:duration= "on" Android: Propertyname= "Alpha" android:valuefrom= "0.0" android:valueto= "1.0" android:valuetype= "Floattype" ></ Objectanimator>animator Animator = Animatorinflater.loadanimator (Loginalphaanimation.this, R.animator.alpha_ login); Animator.settarget (Mimageview); Animator.start ();

Animatorset---Combo animation

Objectanimator Animator1 = objectanimator.offloat (ImageView, "ScaleX", 1f, 2f); Objectanimator Animator2 = Objectanimator.offloat (ImageView, "ScaleY", 1f, 2f); Objectanimator Animator3 = Objectanimator.offloat (ImageView, " Translationy ", 0f, 500f); Objectanimator Animator4 = Objectanimator.offloat (ImageView," Alpha ", 1.0f, 0f); Animatorset set = new Animatorset (); set.setduration (+); Set.playtogether (Animator1, Animator2, Animator3,animator4 ); Set.start ();


Download Demo



Android Animation use

Related Article

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.