Android Animation 2

Source: Internet
Author: User

I wrote Android animation 1 a long time ago, but it was just fun to play, and a lot of knowledge was not complete.

Now summarize.

Basic Android animations are: pan, rotate, zoom, and transparency.

Here's an example:

First Look at panning:

Fromxtype  The type of horizontal play Fromxvalue start with, 0 represents the current position toxtype,   to what location type Toxvalue to what coordinates fromytype the type of vertical play fromyvalue from where to start, 0 indicates the current position toytype to what position the type Toyvalue to what coordinates translateanimation translate = new Translateanimation (            animation.relative_ To_self,-2,             animation.relative_to_self, 2,             animation.relative_to_self, 0,            animation.relative_to_self , 1);    Set display time    translate.setduration (+);    Play resource for Infinite loop    translate.setrepeatcount (animation.infinite);    Playback mode, anti-retransmission put, the first along the end of the broadcast, on the opposite play    Translate.setrepeatmode (animation.reverse);    Which component is playing, set    imageview.setanimation (translate);    Start playing    Translate.start ();

Rotating:

/     * * fromdegrees, starting from what angle 0 from now todegrees, 270 degrees Pivotxtype, x center point type     * animation.relative_to_self itself pivotxvalue, medium The heart point value of 0.5 indicates that the image is half-     pivotytype, y-center-point type animation.relative_to_self itself     *  pivotyvalue 0.5f    */ Rotateanimation rotate = new Rotateanimation (0, Animation.relative_to_self,            0.5f, animation.relative_to_self ,            3);    Playback display time    rotate.setduration (;    Rotate.setrepeatcount (animation.infinite);    Rotate.setrepeatmode (Animation.restart);    Imageview.setanimation (rotate);    Rotate.start ();

Scaling:

/     * * FromX, ToX, from the coordinates of what address start to what coordinates, 0, represents the current FromY, ToY,      * pivotxtype,  the center of rotation     * pivotxvalue, type, Pivotytype, Pivotyvalue     *    /scaleanimation scale = new Scaleanimation (1, 2, 1,-2            , Animation.relative_to_self,-2, Animation.relative_to_self, 3);    Playback display time    scale.setduration (;    Scale.setrepeatcount (animation.infinite);    Scale.setrepeatmode (Animation.restart);    Imageview.setanimation (scale);    Scale.start ();

Final transparency:

       /* * Fromalpha,  from what transparency starts     * Toalpha to what transparency ends *    /alphaanimation alpha = new Alphaanimation (1, 0 );    Playback display time    alpha.setduration (+);    Alpha.setrepeatcount (animation.infinite);    Alpha.setrepeatmode (animation.reverse);            Imageview.setanimation (Alpha);            Alpha.start ();}

Android Animation 2

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.