The recent two days to learn the knowledge of Android animation, from a point of no understanding of their own research is indeed a harvest.
Animation is divided into:
<alpha/> |
Transparency Gradient |
<scale/> |
Size gradient |
<translate/> |
Displacement animation |
<rotate/> |
Rotate animation |
can be defined in XML and in Javacode, respectively, by
in XML |
In Javacode |
<alpha/> |
Alphanimation |
<scale/> |
Scaleanimation |
<translate/> |
Translateanimation |
<rotate/> |
Rotateanimation |
In the animation, any values related to the coordinates are drawn with the X and Y axes at the position of the first animation,
The outermost green frame represents the mobile screen;
The position of the yellow man is defined, so the position is the reference position, that is, the origin point;
And then according to the direction of the arrow to the X, y-axis positive direction to distinguish positive or negative, that is: negative, positive, left negative, right is positive.
Then explain separately
In XML:
(1) Alpha Transparency Gradient animation
1 <?xml version= "1.0" encoding= "Utf-8"?>2 <set xmlns:android= "/http Schemas.android.com/apk/res/android ">3 <Alpha 4 Android:duration= "5 android:fromalpha=" 0 "6 android:toalpha=" 1.0 "7 />8 9 </set>
at the beginning of each animation to start and end with this animation <alpha/>, such as the above code;
Fromalpha: The beginning of transparency;
Toalpha: final transparency;
Transparency: 0 is completely transparent,
1 is completely opaque,
the transparency is represented by the float character type from 0.0~1.0;
Duratiion: Animation completion time (animation within how many MS);
Startoffset: Run the animation after a certain time delay;
(2) Scale size gradient animation
1 <?xml version= "1.0" encoding= "Utf-8"? > <set xmlns:android=" Http://schemas.android.com/apk/res/android " > <scale 4 android:duration= " 5 android:fromxscale=" 0.1 " 6 android:toxscale= "1.0" 7 android:fromyscale=" 0.1 " android:toyscale=" 1.0 " 9 android:pivoty= "10 android:pivotx=" 11 />12 13 </set>
Fromxscale: Scaling dimensions on X-coordinates at start of animation
Toxscale: Stretch size on x-coordinate at end of animation
Fromyscale: Scaling dimensions on y-coordinates at start of animation
Toyscale: Stretch size on y-coordinate at end of animation
the above four properties are floating-point value types: 0.0 means zero size
small size between 0.0~1.0 (reduced original picture)
1.0 represents the original size without scaling
>1.0 for large size (enlarged original picture)
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 y-coordinate of the object
The above two attribute values are taken from the 0%-100%, and 50% is the midpoint position on the x or Y coordinate of the object;
Duratiion: Animation completion time (animation within how many MS);
Startoffset: Run the animation after a certain time delay;
(3) Translate displacement animation
1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <set xmlns:android= "/http Schemas.android.com/apk/res/android "> 3 <translate 4 android:duration=" 2000 " c6> 5 android:fromydelta= " 6 android:fromxdelta=" 7 Android:toxdelta= " -30" 8 android:toydelta= " -30" 9 /> </set>
Fromxdelta: The x-coordinate at the beginning of the animation;
Toxdelta: The x-coordinate at the end of the animation;
Fromxdelta: The y-coordinate at the beginning of the animation;
Toydelta: The y-coordinate at the end of the animation;
Duratiion: Animation completion time (animation within how many MS);
Startoffset: Run the animation after a certain time delay;
(4) Rotate rotation animation
1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <set xmlns:android= "/http Schemas.android.com/apk/res/android "> 3 <rotate 4 android:duration=" 5 android:fromdegrees= "0" 6 android:todegrees= " 7 android:pivotx=" 50 " c9> 8 android:pivoty= " 9 /> </set>
Formdegreea: Animation start angle;
Todegreea: Animation at the end of the angle, can be greater than 360 °, (more than 360 ° is able to rotate a few laps, you can try it yourself);
When the angle is negative--indicates counterclockwise rotation when the angle is positive--indicates a clockwise rotation (negative from--to positive: clockwise rotation) (negative from--to negative: counterclockwise rotation) (positive from--to positive: clockwise rotation)
Pivotx,pivoty:
A value of 50% from the 0%-100% is the midpoint position of the object in the x or y-direction coordinates;
Duratiion: Animation completion time (animation within how many MS);
Startoffset: Run the animation after a certain time delay;
Some effects:
@android: anim/accelerate_interpolator: Getting faster
@android: anim/decelerate_interpolator: Getting slower
@android: Anim/accelerate_decelerate_interpolator: Fast and slow first
@android: anim/anticipate_interpolator: Take a small step back and speed it forward.
@android: Anim/overshoot_interpolator: Quickly reach the end of a small step and return to the end
@android: Anim/anticipate_overshoot_interpolator: Reach the end of a small step and return to the end
@android: Anim/bounce_interpolator: Reach the end to produce a pinball effect and bounce back to the end
@android: anim/linear_interpolator: Uniform speed.
But I've tried to find out that writing in XML doesn't actually work, and to invoke in Javacode to show the effect:
To add this code to Javacode, you can try it yourself:
Myanimation.setinterpolator (New Bounceinterpolator ()); Pinball effect;
Learn the basis of their own can be in-depth study of the next, such as I found that this will be better to see OH:
1< Scale2Android:duration= "2000"3Android:fromyscale= "0DP"4Android:toyscale= "1.0"5android:fromxscale= "0"6Android:toxscale= "1.0"7Android:pivoty= "50"8android:pivotx= "50"9/>Ten One<Translate AAndroid:duration= "2000" -Android:fromydelta= "20%p" -Android:toydelta= "0" the/>
after the size scaling and displacement add up, and then call the pinball effect in the Javacode, out of the picture is really more good-looking ha haha (unintentional lifting);
But still did not try to come out of the continuous animation, and frame to play a different kind, continue to work and then add it ~
2016-08-16 22:41:12
Android Animation Animation Learning Notes