Basic learning of frame animation of Android animation
preface
In Android, there are two ways to implement Animation: tween animation and frame animation. Gradient animation produces animation effects by constantly making image transformations (translation, scaling, rotation, etc.) on the objects in the scene. Frame animation is to play the prepared images in sequence to produce animation effects, similar to movies.
Let's learn the basic knowledge of frame by frame animation in Android.
Principle: visual persistence of human eyes
Method:
1. In Java code (New animationdrawable(). Addframe (getdrawable (r.drawable. A), 200);)
SDK seems to require that the minimum version must be > = 21
2. Define animation resources in XML file
The renderings are as follows
code
1. Prepare picture resources
Put the picture resources in the drawable hdpi directory
2. Create an animation list file in the drawable directory
anim_ frame. xml
3. In the layout file, add ImageView and set its background attribute to the animation resource XML
activity_ main. xml
4. In Java, get the animation resources, call start() to start the animation, and stop() to stop the animation
summary
The above is the whole content of this article. I hope it can be helpful to Android developers. If you have any questions, you can leave a message.