1. Tween generates animations based on the object properties (position, alpha value (transparency), size, angle, etc.) and the length of time the animation is played, depending on the start and end of the specified animation;
2, frame specifies the picture and the length of time each frame plays. Animation method: 1, in the project's Res folder to create an animation resource XML file, automatically added to the project's resource class R, the program is then loaded from the resource class animation to use; 2. Create animation objects directly in the program code and set related properties. Method: 1, create a new Anim folder under the Res folder, create a new XML file under the Anim folder, select the set type, 2, in the XML file, create a new animation type label, such as <scale ></scale> and so on; 3. Load in program code using (rotate.xml): Animation anim = animationutils.loadanimation (Mainactivity.this, r.anim.rotate); Mbtn.startanimation (ANIM); Or when jumping between activity (the first one is to exit the animation, the second is to show the animation): Overridependingtransition (R.anim.fade, r.anim.hold); View Animation (Tween Animation) is placed within the/res/anim/folder with an XML-defined animation, and the root element of the XML file can be <alpha>,<scale>,<translate >,<rotate>,interpolator element or <set> (represents the set of several animations above, set can be nested). By default, all animations are performed simultaneously, and the start offset (start time) of each animation can be set by the Startoffset property to achieve the effect of animation order playback. Tween 4 Animation effect:
|
|
|
| interpolator |
@android: ANIM/ACC Elerate_decelerate_interpolator |
middle fast backward |
| setting change speed |
@android: anim/linear_interpolator |
|
| ; |
@android: Anim/accelerate_interpolator |
getting faster |
| &NBSP; |
@android: anim/decelerate_interpolator |
more The slower |
| startoffset |
|
wait for milliseconds to start animation |
| duration |
|
animation duration millisecond Time |
1. Alpha:
| Property name |
Property value |
Description |
| Fromalpha |
0~1 |
Transparency at Start |
| Toalpha |
0~1 |
End-of-time transparency |
2. Scale
| Property name |
Property value |
Description |
| Fromxscale |
0~ |
At the beginning of the X-direction size ratio, more than 1 represents amplification |
| Toxscale |
0~ |
At the end of the X-direction size ratio, more than 1 represents amplification |
| Pivotx |
0~1 |
The x-coordinate of the image at the beginning, 0 for the leftmost, and 1 for the rightmost |
3, Translate
| Property name |
Property value |
Description |
| Fromxdelta |
Integer value |
The offset of the x-coordinate at the beginning |
| Toxdelta |
Integer value |
The offset of the x-coordinate at the end |
4, Rotate
| Property name |
Property value |
Description |
| Fromdegrees |
Integer value |
Angle at start |
| Todegrees |
Integer value |
Angle at end |
| Pivotx |
0~1 |
The x-coordinate of the image at the beginning, 0 for the leftmost, and 1 for the rightmost |
Drawable Animation (Frame Animation):
Must take <animation-list> as the root element, oneshot to true means play only once from beginning to end, false for repeated playback, <item> represents the picture to rotate, and the Duration property represents the time that the items are displayed. The XML file is to be in the/res/drawable/directory.
<?xml version= "1.0" encoding= "Utf-8"?> <animation-list xmlns:android= "http://schemas.android.com/apk /res/android " android:oneshot=" false " > <item android:drawable=" @drawable/dice01 "Android: duration= "></item> <item android:drawable=" @drawable/dice02 "android:duration=" item> <item android:drawable= "@drawable/dice03" android:duration= "></item> <item" android:drawable= "@drawable/dice04" android:duration= "></item> <item android:drawable=" @ Drawable/dice05 "android:duration=" ></item> <item android:drawable= "@drawable/dice06" Android :d "uration=" ></item> </animation-list>
Program loading: Resources res = getresources (); Animationdrawable Animdraw = (animationdrawable) res.getdrawable (r.drawable.anim_drawable); or direct code creation: animationdrawable Animdraw = new animationdrawable (); Animdraw.setoneshot (false); Resources res = getresources (); Animdraw.addframe (Res.getdrawable (R.DRAWABLE.IMG01), animdraw.addframe); Res.getdrawable (R.DRAWABLE.IMG02), 100); Play Animation: Imgview.setimagedrawable (Animdraw); Animdraw.start (); Animdraw.stop ();
Android Animation effect Animation