Android program development - Master the use of frame-by-frame animation, tween animation, Alpha (transparency), animation Scale (zoom) animation Translate (bit) movement animation Rotate (rotation) animation in Android multimedia animation playback

Multimedia animation playback application

1.1 Experimental purpose

   Master the use of Android multimedia animation playback

1.2 Experimental steps

1. Create an Android application and create MainActivity.

2. Add the control code in the activity_main main layout file

3. Add the animated xml file to the drawable folder

4. Add animation initialization code to MainActivity, and write frame-by-frame animation and tween animation respectively.

1.3 实验代码

1. Create a project

2. Write the initialization code for frame-by-frame animation, and add the control code in the activity_main main layout file:

2.1 Add the frame_animation.xml initialization code of the animation to the drawable folder, and place all the image files in the drawable folder.

2.2 Add imageView initialization code to MainActivity

3. Start a new project and follow the steps to complete the usage of tween animation. Add the following code to the activity_main main layout file and place the images used in the code into the drawable folder.

Add anim folder under the res folder to store animation xml files

How to edit tweened animations separately

alpha.xml

rotate.xml

scale.xml

translate.xml
tween.xml
Add the following code to MainActivity

Experimental effect

1.4 Experimental Summary

1, Frame )

Frame-by-frame animation in Android is the simple process of continuously displaying a series of images at short intervals, so that the final effect is a moving or changing object.

Before developing frame-by-frame animation, you first need to plan the animation sequence using a series of images.

2, Tween animation (Tween)

Tween animation is a way to set the start state and end state of animation, and the changes in the middle are supplemented by system calculations. Tween animation is implemented by the Animation class to achieve specific effects, including four subclasses and four variations:

1. TranslateAnimation

2. Scale(ScaleAnimation)

3. Rotate(RotateAnimation)

4, Transparency (AlphaAnimation)

It can be implemented through xml or java code.

(1)Alpha (transparency) animation

When creating a transparency animation, you need to specify the transparency at the beginning of the animation, the transparency at the end, and the duration of the animation. Transparency values ​​range from 0.0 to 1.0.

1.0 means the transparency is completely opaque, and 0.0 means completely transparent.

(2)Scale animation

When creating a scaling animation effect, you need to specify the scaling ratio at the beginning of the animation, the scaling ratio at the end, and specify the duration of the animation. Since the scaling effect of the scaling animation is different from to the same reference point, it is also necessary to specify the scaling center point of the scaling animation.

(3)Translate (bit) moving animation

When creating a displacement animation, you need to specify the position when the animation starts, the position when it ends, and the duration of the animation.

(4)Rotate animation

When creating a rotation animation, you need to specify the rotation angle at the beginning and end of the animation.

The rotation angle and animation duration. Due to rotation animation to different points

The effects of center rotation are different, so you also need to know how to specify the "rotation axis"

coordinate of.

Property description:

android: fromDegrees

Rotation start angle, positive number indicates clockwise direction, negative number indicates counterclockwise direction.

android: toDegrees

End angle of rotation, positive number indicates clockwise direction, negative number indicates counterclockwise direction.

android: pivotX

The X coordinate of the rotation center point.

android:pivotY

The Y coordinate of the rotation center point.

Guess you like

Origin blog.csdn.net/WZY22502701/article/details/134230457