Brief introduction
Android animation mainly includes view animation and property animation, view animation includes tween animation and frame animation, tween animation includes gradient animation, translation animation, scaling animation, rotating animation.
Basic properties of Tween animation
Target View;
often duration;
Start state fromxxx;
End animation ToXxx;
Start time startoffset;
Repetition times repeatcount;
Timeline Interpolator (interpolation).
code example
XML implementation
<?xml version= "1.0" encoding= "Utf-8"?> <translate xmlns:android=
"http://schemas.android.com/apk/res/" Android "
android:fromxdelta=" 0 "
android:fromydelta=" 0 "
android:toxdelta=" 100% "
android: Toydelta= "0"
android:fillafter= "true"
android:duration= "3000" >
</translate>
Calling in code
Animation translate = animationutils.loadanimation (context,r.anim.translate);
Imageview.startanimation (translate);
Add:
1. For zooming and rotating animations, there pivotX
is one or the pivotY
center point for zooming or rotating.
The corresponding attribute values are written in three ways.
· A value of 50 indicates the upper-left corner of the current control plus 50px;
· A percentage of 50% represents 50% of the current control;
· The percentage p 50%p represents 50% of the parent control.
2. In an animation set, you can stratOffset
implement multiple animation parallelism and serial effects by setting properties.
Frame animation
The configuration file for frame animation is placed in the drawable directory
<?xml version= "1.0" encoding= "Utf-8"?> <animation-list xmlns:android=
"http://schemas.android.com/apk" /res/android ">
<item android:drawable=" @drawable/image1 "android:duration="/> <item
android:drawable= "@drawable/image2" android:duration= "/> <item android:drawable="
@drawable/image3 " Android:duration= "/>"
</animation-list>
The background
Imageview.setbackgroundresource (R.drawable.frame_anim) need to be set first;
Animationdrawable frameanimation = (animationdrawable) imageview.getbackground ();
Frameanimation.start ();
Summarize
The above is the entire content of this article, I hope this article can be useful for everyone to develop Android, if there is doubt you can message exchange.