Android Siege Lion Animation combo

Source: Internet
Author: User

Combo Animation Case One (cont. 1):    Two animations A and B, play animation A, set A's Animationlistener (rewrite 3 methods), when one of the methods Onanimationend () triggers, That is, when a is finished, start playing B. The core code is as follows: Animation loadanimation = Animationutils.loadanimation (this, r.anim.translate); Image.startanimation (loadanimation); Turn on animation aanimation LoadAnimation2 = Animationutils.loadanimation (this, r.anim.rotate); Loadanimation.setanimationlistener (New Animationlistener () {    ///Inherits three methods, but only overrides the end method    @Override public    Void Onanimationstart (Animation arg0) {}    @Override public    void Onanimationrepeat (Animation arg0) {}    @Override Public    void Onanimationend (Animation arg0) {image.startanimation (loadAnimation2);} Turn on animation B});

Case Two (continued 2):    Write an animation set Animationset, where you define animations A and B, set startoffset for animation B, and its value is the time it takes for the previous animation to play. The example given here does not use the listener, but is written in the animation's configuration file. , continuously write two <alpha> animations, to achieve the image from transparent to opaque, and then from opaque to transparent and then into two consecutive animation. Code: <alpha    android:duration= "" "    android:fromalpha=" 0.2 "android:toalpha=" 1.0 "/><alpha    android:duration= "android:fromalpha="    1.0 "    android:startoffset="    android:toalpha= " 0.2 "/>

Case Three (circular flicker)    uses animation's setrepeatcount and Setrepeatmode to realize the animation loop. , implemented by code: alphaanimation alphaanimation = new Animation (0.1f, 1.0f); alphaanimation.setduration (100); Alphaanimation.setrepeatcount (Alphaanimation.setrepeatmode); (animation.reverse);//Reverse Repeat image.startanimation ( alphaanimation), or change REVERSE to RESTART if you want to repeat the sequence.

case Four (activity Toggle animation): This is the animation that jumps from one activity to another. Use the Overridependingtransition method. Passed in parameters: The second activity enters the animation, the first activity exits when the animation. (Note the order of the Parameters) code: Intent Intent = new Intent (mainactivity.this, Mainactivity2.class); startactivity (Intent); o Verridependingtransition (r.ainm.zoom_in, r.anim.zoom_out); r.ainm.zoom_in and r.anim.zoom_out are our custom animations.





Android Siege Lion Animation combo

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.