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