Type of animation
Android animation is made up of four different types
in XML
Alpha |
Gradient Transparency Animation effect |
Scale |
Gradient Dimension Stretch animation effect |
Translate |
Move animation effect on picture transition position |
Rotate |
Picture Transfer rotation animation effect |
In Javacode
Alphaanimation |
Gradient Transparency Animation effect |
Scaleanimation |
Gradient Dimension Stretch animation effect |
Translateanimation |
Move animation effect on picture transition position |
Rotateanimation |
Picture Transfer rotation animation effect |
Android Animation mode
Animation There are two main modes of animation:
One is tweened animation (gradient animation)
in XML |
Javacode |
Alpha |
Alphaanimation |
Scale |
Scaleanimation |
One is frame by frame (Picture conversion animation)
in XML |
Javacode |
Translate |
Translateanimation |
Rotate |
Rotateanimation |
Android Animation parsing
Alpha XML fade Out effect
[CPP]View PlainCopy
- <?xml version="1.0" encoding="Utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android" >
- <alpha
- Android:fromalpha="1.0"
- android:toalpha="0.0"
- android:duration="/> "
- </set>
- <!--
- Fromalpha: Transparency at start
- Toalpha: End-of-time transparency
- Duration: Animation Duration--
Alpha XML fade-in effect
[CPP]View PlainCopy
- <?xml version="1.0" encoding="Utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android" >
- <alpha
- android:fromalpha="0.0"
- Android:toalpha="1.0"
- android:duration="/> "
- </set>
- <!--
- Fromalpha: Transparency at start
- Toalpha: End-of-time transparency
- Duration: Animation Duration--
rotate.xml Rotation effect:
[HTML]View PlainCopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <set xmlns: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 clockwise
- The Pivotx property is the start position of the animation relative to the X coordinate of the object
- The Pivoty property is the start position of the animation relative to the object's y-coordinate->
scale.xml Zoom Effect:
[CPP]View PlainCopy
- <?xml version="1.0" encoding="Utf-8"?>
- <set xmlns: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>
- <!--
- Fromxdelta,fromydelta at the beginning of the x, y coordinates, the lower right corner of the screen is the coordinates x:320,y:480
- Toxdelta, Toydelta, x, y coordinates at the end of the animation <!--
- Interpolator Specifying an animation insert
- Common with acceleration reducer accelerate_decelerate_interpolator
- Accelerate the accelerate_interpolator of the insertion device,
- decelerate the insertion device decelerate_interpolator.
- Fromxscale,fromyscale, the scale of X, y before the start of the animation, 0.0 for not showing, 1.0 for normal size
- Toxscale,toyscale, the multiple of the final zoom of the animation, 1.0 for normal size, greater than 1.0 magnification
- Pivotx, Pivoty animation start position, relative to the screen percentage, two are 50% means the animation starts from the middle of the screen
- Startoffset, the interval of time that the animation is executed more than once, which pauses the time before execution,
- Unit millisecond duration, the time that the animation effect consumes, the unit 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 is in the opposite direction.
- Restart for re-execution, no change in direction--
translate.xml Move Effect:
[HTML]View PlainCopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <set xmlns: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>
- <!--
- Fromxdelta,fromydelta at the beginning of the x, y coordinates, the lower right corner of the screen is the coordinates x:320,y:480
- Toxdelta, Toydelta the coordinates of x, y at the end of the animation->
Android animation effects translate, scale, alpha, rotate detailed