A motion tween is a developer who only needs to specify the start of the animation, the "Keyframe" of the end of the animation, and the "middle frame" of the animation change is computed by the system and is padded. This is the tweened animation.
tweened animations are divided into four categories:
Alphaanimation (transparent animation), scaleanimation (zoom animation), translateanimation (displacement animation), roateanimation (rotate animation)
We learn in turn.
A: Transparent animation
public void Alphaanimation (View v) { ///0: Represents full transparency, 1 represents a full opaque AA = new Alphaanimation (0, 1); Duration 2s aa.setduration (+); Start play animation iview.startanimation (AA); }
Transparent animations only need to set the start transparency, and end the transparency, as well as set the animation delay time on the line.
B: Zoom Animation
public void Scaleanimation (View v) {/ * 1: Represents the initial value of the x-coordinate = 1*iview's width * 3: Represents the x-coordinate's zoom position = 3*iview's width * The default scaling origin is the upper-left corner. * * ///sa = new Scaleanimation (1, 3, 1, 3); Iview.getwidth ()/2, Iview.getheight ()/2: You can modify the origin of the zoom, which is the center of the ImageView as the zoom point //sa = new Scaleanimation (0, 3, 0, 3, Iview.getwidth ()/2, Iview.getheight ()/2); Animation.relative_to_self, 1: Represents the x-coordinate of the zoom point = The iview's true x+1*iview width //animation.relative_to_self, 1: Represents the y-coordinate of the zoom point = iview true y+1*iview height sa = new Scaleanimation (0, 2, 0, 2, animation.relative_to_self, 1, animation.relative_ To_self, 1); Set delay Time sa.setduration (+); Iview.startanimation (SA); }
Scaling animation has 3 refactoring methods, each method parameters are not the same, build everyone try to set a few values to try to understand the meaning of the.
C: Displacement animation
public void Translateanimation (View v) { //0: Indicates the starting position of the x-coordinate = iview true x + 0 //ta = new Translateanimation (0 , 0, (+); Animation.relative_to_self, 1: Indicates the start coordinate of x = IView's true x + IV Width * * ta = new Translateanimation (animation.relative_to_ Self, 1, animation.relative_to_self, 1, animation.relative_to_self, 1, animation.relative_to_self, 1); Ta.setduration (+); Iview.startanimation (TA); }
There are two ways to construct displacement animation, and you need to try it yourself.
D: Rotate Animation
public void rotateanimation (view v) { //rotation start angle and end angle //ra = new Rotateanimation (0, -15); RA = new Rotateanimation (iview.getwidth)/2, Iview.getheight ()/2); RA = new Rotateanimation (0, animation.relative_to_self, 1, animation.relative_to_self, 1); Ra.setduration (+); Iview.startanimation (RA); }
Summary: tweened animations only need to remember three important elements, starting coordinates, ending coordinates, and animation playback time.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Learning Tween (Tween) animation