? ? Reprint Please specify Source: http://blog.csdn.net/zhaokaiqiang1992
? ? We were able to use the View Animation animation system to add tween animations ("Motion tweens") to the view controls, and the motion tweens were calculated by calculating some of the animation parameters, such as Start point, end point, size, rotation angle, and some other animation parameters. To achieve animation effects.
? ? tweened animations can add a series of simple transformations to a view object. For example, position, size, angle, or transparency. So, suppose you have a TextView object. You can move, rotate, or grow larger.
Let's say it has a background image, and the background image changes with the text.
???? http://developer.android.com/reference/android/view/animation/package-summary.html This address provides all the classes required for a tweened animation.
? ? A series of animation instructions are defined as motion tweens, and we are able to define them using XML files or pure code. When we want to define a layout. XML files are more convenient because they are hard-coded relative to each other. It is readable, reusable, and easy to replace. So, in the following example, we will use the XML method (to learn a lot of other information about hard-coded rather than XML, see the Animationset class and animation subclasses).
? ? We can set properties to determine when we want the animation to happen, how long it lasts, and so on.
The animation can be transformed in sequence, or it can happen at the same time. Example. We can move a textview from left to right, then rotate 180 degrees. Or, we can make moving animations and rotation animations happen at the same time.
Each animation transformation needs to set its own unique collection of properties (size changes need to set start and end size, rotation changes need to set the starting angle and end angle, others are similar), but also need to set some common properties, such as start time and duration.
Suppose we want to make very many transformations happen together and give them the same start time. Assuming that you want the transformation order to happen, we just need to set the start time to the total duration of the previous animation.
Suppose we want to create an animation from an XML file, we need to create a Anim folder under Project's Res folder. The file must have only one root element. For example <alpha>,<scale>,<translate>,<rotate>, interpolator element. Or a <set> element that includes these animated elements (and can also include a set element). Let's say we want the animation order to happen, for example, to set a separate Startoffset property. Just like the following example.
? ? The following XML file is from Apidemo, which is used to scale and then rotate a view object at the same time.
<set android:shareinterpolator= "false" > <scale android:interpolator= "@android: Anim/accelerate_decelerat E_interpolator "android:fromxscale=" 1.0 "android:toxscale=" 1.4 "android:fromyscale=" 1.0 "Andro id:toyscale= "0.6" android:pivotx= "50%" android:pivoty= "50%" android:fillafter= "false" Android: duration= "/> <set android:interpolator=" @android: Anim/decelerate_interpolator "> <scale android:fromxscale= "1.4" android:toxscale= "0.0" android:fromyscale= "0.6" android:toyscale= "0.0" android:pivotx= "50%" android:pivoty= "50%" android:startoffset= "" "Android: Duration= "android:fillbefore=" false "/> <rotate android:fromdegrees=" 0 "an Droid:todegrees= " -45" android:toyscale= "0.0" android:pivotx= "50%" android:pivoty= "50%" Android:startoffset= "android:duration="/> </set></set>
? ?The coordinate system of the screen (0. 0) Click on the top left corner of the screen. The right is the x positive coordinate, and the downward is the positive coordinate of Y.
? ? Some values, such as Pivotx, can be specified to be related to themselves or to the parent class. Make sure that the format you use is the correct format for the effect you want, for example, 50% is 50% relative to itself, but 50 is different.
? ? We can also specify a interpolator (interpolator) to determine how the time of the transformation changes. Android includes several middle Interpolator subclasses. Each has its own acceleration curve. Accelerateinterpolator, for example, tells the transformation to be slower at the beginning. And then start accelerating. We are able to set related properties within the XML.
? ? Suppose we call the above code Hyperspace_jump.xml, then we use the following code. Adds an animation to a ImageView control.
? ??
ImageView spaceshipimage = (ImageView) Findviewbyid (r.id.spaceshipimage); Animation hyperspacejumpanimation = Animationutils.loadanimation (this, r.anim.hyperspace_jump); Spaceshipimage.startanimation (hyperspacejumpanimation);
? ?as an optional way of Startanimatinon (). We can use Animation,setstarttime () to set the start time. Then use View,setanimation () to set the animation
? ? If you want to know a lot about other XML usage methods and optional tag properties, check out the animation Resources.
? ? Note:
? ? Regardless of whether your animation is moving or shrinking, the bounds of the animated view control are not self-adjusting, and even so, the animation will still be drawn out, in time beyond the boundaries and will not be split. However, assuming that the animation is outside the scope of the parent view, the out-of-section is split.
? ? Original address: http://developer.android.com/guide/topics/graphics/view-animation.html
"Android Interface Implementation" View Animation usage Introduction