Animation Usage Details
I found many instances of Animation on the Internet and directly pasted the code, but the code was written inexplicably. So I went to the network and found several basic instances, after reading the api and writing down what you know, there may also be errors.
I. api knowledge:
Android. view. animation: Here is the api of the package where the Animation class is located. After reading the api, we can see that there are two types of animations in android: tweened animation and frame-by-frame animation; the former implements a simple transformation (location, size, angle, etc.), and feels a little similar to the shape compensation in Flash. The latter implements a transformation between the image and the image, which is roughly similar to a slide.
Next, let's look at the implemented interface. There are three methods, namely, the onAnimationStart method, the onAnimationRepeat method, and the onAnimationStartEnd method. There are actually a lot of classes in the package. As we use them today, We only care about these classes: Animation, AnimationSet, AlpahaAnimation, RotateAnimation, and ScaleAnimation. First, you must understand that the first class, Animation is an abstract class and cannot be directly instantiated. The third and fourth classes are subclasses of the First Class. To remember this, the first class is a wide-range Animation, three or five types of detailed animations are transparency-related animations, angle-related animations, and size-related animations. These refined animations have corresponding construction methods, you can add rules directly or use an xml file to construct rules.
I still forget that when I open the Animation class, I can only find that there are many methods and constants in it. One column is XML Attributes. As the name suggests, this is a rule that can be set through xml, the first column is the attribute, and the second column is the method. You can use these methods to set the preceding attributes. This is the method for creating an animation using an xml layout file. The third column is the description. All classes that inherit the Animation can directly call these methods.
An AnimationSet is a set of animations. You can add multiple animations to an AnimationSet to execute an Animation, that is, you can combine AlpahaAnimation and RotateAnimation, scaleAnimation enables an animation that changes the transparency, angle, and size.