View animations in Android

Source: Internet
Author: User

[1] Transparent

//Click the button to achieve IV transparency effect animation     Public voidClick1 (View v) {//1.0 means completely opaque 0.0 means completely transparentAlphaanimation AA =NewAlphaanimation (1.0f, 0.0f); Aa.setduration (2000);//set time for animation executionAa.setrepeatcount (1);//set number of repetitionsAa.setrepeatmode (Animation.reverse);//set the mode of animation execution//IV Start Animationiv.startanimation (AA); }

[2] Rotation

//Click the button implementation IV to perform a rotation animation     Public voidClick2 (View v) {//fromdegrees Start angle todegrees End Angle//rotateanimation ra = new Rotateanimation (0, 360); Rotateanimation RA =NewRotateanimation (0, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Ra.setduration (2000);//set time for animation executionRa.setrepeatcount (1);//set number of repetitionsRa.setrepeatmode (Animation.reverse);//set the mode of animation execution//IV Start Animationiv.startanimation (RA); }

[3] Scaling

 //  Click the button to make a zoom animation  public  void   Click3 (View v) {Scaleanima tion sa  = new  scaleanimation (1.0f,2.0f, 1.0f, 2.0f, animation.relative_to        _self, 0.5f, animation.relative_to_self, 0.5f); Sa.setduration ( 2000); //  Set the time of the animation execution  Sa.setrepeatcount (1); //  Set the number of repetitions  sa.setrepeatmode (animation.reverse); //  Set the mode of animation execution  // iv start animation      Iv.startanimation (SA); }

[4 "displacement

  public    void  Click4 (View v) {        new translateanimation ( Animation.relative_to_parent, 0, animation.relative_to_parent, 0, animation.relative_to_parent, 0, Animation.relative_to_parent, 0.2f);         Ta.setduration (// set time for animation execution         ta.setfillafter (true);   When the animation ends, the animation stops at                  the end position // start animation          iv.startanimation (TA);    }

//Animations Fly together     Public voidClick5 (View v) {Animationset set=NewAnimationset (false); //Transparent animationsAlphaanimation AA =NewAlphaanimation (1.0f, 0.0f); Aa.setduration (2000);//set time for animation executionAa.setrepeatcount (1);//set number of repetitionsAa.setrepeatmode (Animation.reverse);//set the mode of animation execution//Rotate AnimationRotateanimation RA =NewRotateanimation (0, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Ra.setduration (2000);//set time for animation executionRa.setrepeatcount (1);//set number of repetitionsRa.setrepeatmode (Animation.reverse);//set the mode of animation execution//ZoomScaleanimation SA =NewScaleanimation (1.0f,2.0f, 1.0f, 2.0f, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Sa.setduration (2000);//set time for animation executionSa.setrepeatcount (1);//set number of repetitionsSa.setrepeatmode (Animation.reverse);//set the mode of animation executiontranslateanimation ta=NewTranslateanimation (animation.relative_to_parent, 0, animation.relative_to_parent, 0, Animation.relative_to_parent, 0, Animation.relative_to_parent, 0.2f); Ta.setduration (2000);//set time for animation executionTa.setfillafter (true);//The animation stops at the end position when the animation ends//Add animationsset.addanimation (AA);        Set.addanimation (RA);        Set.addanimation (SA);                Set.addanimation (TA); //The last step is to remember to perform the animationiv.startanimation (set); }

View animations in Android

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.