View Animation
The view animation system can be used to perform Tween animation and Frame animationon the view.
Tween Animation can perform a series of simple transformations on the view object, such as position, size, rotation, transparency, and so on.
animation packageThe package contains all classes of tween animation.
A series of animation commands define a complete tween animation that can be defined in code or in an XML resource file.
XML resource File
The use of XML resource files can be found in:AnimationResources.
The XML file is placed in the project's res/anim/directory . The file must have a unique root node.
The root node can be: <alpha>, <scale>, <translate>, <rotate>, interpolator element, or <set>.
By default, all animations are performed in parallel, and you must specify the Startoffset property if you want them to occur .
There are some values that can be specified relative to the view itself or relative to the parent class container.
For example Pivotx, to represent 50% relative to itself, to use 50%, to indicate relative to the parent class container 50%, then write directly .
Examples of Use
The XML file is stored as:res/anim/hyperspace_jump.xml:
<SetXmlns:android= "Http://schemas.android.com/apk/res/android"Android:shareinterpolator= "false"><ScaleAndroid:interpolator= "@android: Anim/accelerate_decelerate_interpolator"Android:fromxscale= "1.0"Android:toxscale= "1.4"Android:fromyscale= "1.0"Android:toyscale= "0.6"Android:pivotx= "50%"Android:pivoty= "50%"Android:fillafter= "false"Android:duration= "700"/><SetAndroid:interpolator= "@android: Anim/accelerate_interpolator"Android:startoffset= "700"><ScaleAndroid:fromxscale= "1.4"Android:toxscale= "0.0"Android:fromyscale= "0.6"Android:toyscale= "0.0"Android:pivotx= "50%"Android:pivoty= "50%"Android:duration= "400"/> <rotate android:fromdegrees= "0" Android:todegrees= " -45" Android:toyscale=" 0.0 " Android:pivotx=" 50% " Android:pivoty= "50%" Android:duration= "/> </set ></set>
Apply this animation to a ImageView in your code:
ImageView image = (ImageView) Findviewbyid (r.id.image); Animation hyperspacejump = animationutils.loadanimation (this, r.anim.hyperspace_jump); image.startanimation (hyperspacejump);
In addition to invocation startAnimation() , another way to handle this is to define a start time by using the Animation.setstarttime () method, and then View.setAnimation() assign the animation to the control by means of the method.
View Animation and property Animation
View animation is introduced in API level 1 .
The View animation in the package android.view.animation .
The animation class is called Animation.
Property animation is the API level introduced, that is, the Android 3.0 only started to have the property animation related API.
The property Animation API is in the package android.animation .
The animation-related class is called AnimaTor.
References
API Guides:view Animation
Http://developer.android.com/guide/topics/graphics/view-animation.html
Tween Animation's Package:
Http://developer.android.com/reference/android/view/animation/package-summary.html
Animation class:
Http://developer.android.com/reference/android/view/animation/Animation.html
Animation Resources
Http://developer.android.com/guide/topics/resources/animation-resource.html
Android Animation Learning (vi) View animation introduction