Type of animation
Android animation is made up of four different types
in XML
alpha /td> |
gradient transparency animation effect |
scale |
gradient dimension stretch animation effect |
translate |
picture conversion position Move animation effect |
< Span style= "FONT-SIZE:10.5PT;" >rotate |
Picture transfer rotation animation effect |
javacode
alphaanimatio n |
gradient transparency animation effect |
scaleanimation |
|
translateanimation |
Picture transition position Move animation effect |
rotateanimation |
Picture transfer rotation animation effect |
android animation mode
Animation< Span style= "font-family: the song Body;" > There are two main modes of animation:
tweened Animation (
xml |
javacode |
alpha |
alphaanimation |
scale |
scaleanimation |
One is frame by frame ( picture conversion animation )
xml in |
javacode |
translate |
translateanimation |
rotate |
rotateanimation |
/span>
Android Animation parsing
Alpha XML fade Out effect
<?xml version="1.0"encoding="Utf-8"?> <SetXmlns:android="http://schemas.android.com/apk/res/android"> <Alpha Android:fromalpha="1.0"Android:toalpha="0.0"android:duration=" -"/> </Set> <!--Fromalpha: Start transparency Toalpha: End Transparency Duration: duration of animation-
Alpha XML fade-in effect
<?xml version="1.0"encoding="Utf-8"?> <SetXmlns:android="http://schemas.android.com/apk/res/android"> <Alpha Android:fromalpha="0.0"Android:toalpha="1.0"android:duration=" -"/> </Set> <!--Fromalpha: Start transparency Toalpha: End Transparency Duration: duration of animation-
Rotate.xml Rotation Effect:
<?xml version="1.0"encoding="Utf-8"?> <SetXmlns:android="http://schemas.android.com/apk/res/android"> <Rotate Android:interpolator="@android: Anim/accelerate_decelerate_interpolator"android:fromdegrees=" -"android:todegrees="-360"Android:pivotx="10%"Android:pivoty="100%"android:duration="10000"/> </Set> <!--Fromdegrees the angle at which the animation starts todegrees the rotation angle of the object at the end of the animation, which means that the clockwise Pivotx property is the start position of the animation relative to the object's x-coordinate Pivoty property The start position of the animation relative to the y-coordinate of the object-
Scale.xml Zoom Effect:
<?xml version="1.0"encoding="Utf-8"?> <SetXmlns:android="http://schemas.android.com/apk/res/android"> <Scale Android:interpolator="@android: Anim/decelerate_interpolator"Android:fromxscale="0.0"Android:toxscale="1.5"Android:fromyscale="0.0"Android:toyscale="1.5"Android:pivotx="50%"Android:pivoty="50%"Android:startoffset="0"android:duration="10000"Android:repeatcount="1"Android:repeatmode="Reverse"/> </Set> <!--x, y coordinates at the beginning of the Fromxdelta,fromydelta, and the coordinates in the lower right corner of the screen are ×: theY:480Toxdelta, Toydelta x, y coordinates at the end of the animation-<!--interpolator Specifies that the animation insert is common with an acceleration reducer accelerate_decelerate_interpolator acceleration Plug Accelerate_interpolator, decelerate the decelerate_interpolator of the insertion device. Fromxscale,fromyscale, the scale of X, y before the animation starts,0.0 is not displayed,1. 0 for normal size Toxscale,toyscale, the multiple of the final zoom of the animation,1. 0 is normal size, greater than 1.0 magnification Pivotx, pivoty animation start position, relative to the screen percentage, two are%indicates that the animation starts startoffset from the middle of the screen, the interval of time when the animation is executed more than once, and pauses the time before execution, in milliseconds duration, a The time that the animation effect consumes, in milliseconds, the smaller the value the faster the animation repeatcount, the animation repeats the count, the animation will execute the value+1 times Repeatmode, the animation repeats the pattern, the reverse is reversed, and when the first even executes, the animation will be in the opposite direction. Restart for re-execution, direction unchanged-
Translate.xml Move Effect:
<?xml version="1.0"encoding="Utf-8"?> <SetXmlns:android="http://schemas.android.com/apk/res/android"> <Translate Android:fromxdelta=" the"Android:toxdelta="0"Android:fromydelta="480"Android:toydelta="0"android:duration="10000"/> </Set> <!--x, y coordinates at the beginning of the Fromxdelta,fromydelta, and the coordinates in the lower right corner of the screen are ×: theY:480Toxdelta, Toydelta x, y coordinates at the end of the animation-
xmlandroid animation effects translate, scale, alpha, rotate detailed