(Ah, I accidentally deleted this article and had to come back without backup .)
In the view-> animation of the API demo, you can find four animation demos. The first 3D translate is complicated. Finally, let's talk about it. Let's talk about 2nd interpolators first. The activity corresponds to animation3.java in the View package and layout's animation_3.xml.
The layout of the interface is not explained. It is just a spinner and a textview. Not in this article.
Mainly explain several key statements.
Initialize animation. From the class name, we can see that it is an animation that changes the position of the view. It refers to the parameter's start point abscissa, end point abscissa, start point ordinate, and end point ordinate.
Animation A = new translateanimation (0.0f, <br/> targetparent. getwidth ()-target. getwidth ()-targetparent. getpaddingleft ()-<br/> targetparent. getpaddingright (), 0.0f, 0.0f );
Below is the animation parameter settings. I added a comment
A. setduration (1000); // set the animation time <br/>. setstartoffset (300); // sets the animation startup latency <br/> // sets the recurrence mode, and restart starts after the restart ends, reverse returns a reverse result based on the original trajectory. <br/>. setrepeatmode (animation. restart); <br/> // set the number of repeat times. Infinite is unlimited <br/>. setrepeatcount (animation. infinite); <br/> // set the target entry mode based on the user's choice in the spinner <br/> switch (position) {<br/> case 0: <br/> // enter the accelerator <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. accelerate_interpolator); <br/> break; <br/> case 1: <br/> // slow down to <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. decelerate_interpolator); <br/> break; <br/> case 2: <br/> // enter acceleration. the difference from the first one is that when repeatmode is reverse, the origin is still returned for acceleration. <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. accelerate_decelerate_interpolator); <br/> break; <br/> case 3: <br/> // move back a bit before accelerating the process <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. anticipate_interpolator); <br/> break; <br/> case 4: <br/> // speed down and move back before the end point. <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. overshoot_interpolator); <br/> break; <br/> case 5: <br/> // a combination of case 4 and 4 <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. anticipate_overshoot_interpolator); <br/> break; <br/> case 6: <br/> // returns a few rounds before stopping <br/>. setinterpolator (animationutils. loadinterpolator (this, <br/> android. r. anim. bounce_interpolator); <br/> break; <br/>}< br/> // Let the target start executing the animation <br/> target. startanimation (a); <br/>}
Here we use some preset actions of Android. We can also customize XML to achieve better animation effects. Next, let's talk about it.
In addition to translationanimation, alphaanimation, rotateanimation, and scaleanimation, the combination of these matrix actions can form a series of complex animated effects. For more information about the usage, see the SDK.
The whole process is relatively simple. Just look at the API comments and SDK documents without understanding how to call a function.