Android realizes the effect of text flipping animation

This paper implements a small program for text flip animation of Android program, and the specific code is as follows:

The first rendering is as follows:

requirement:

Looking along the positive direction of Y axis, the animation rotates counterclockwise when the value decreases by 1, and clockwise when the value increases by 1.

See "rotateanimation. Java" for details of realizing animation. To facilitate viewing the rotation direction of the animation, rotate animation Set the debug value to true. 


Rotateanimation refers to rotate3danimation 
 from apidemos

The rotateanimation constructor needs three parameters, which respectively describe the center point position and rotation direction of the animation component. 


RotateAnimation. Initialize() initializes the width and height of the animation component and its parent container; Generally, other initialization work can also be carried out. In this example, it is used to instantiate and assign values to camera. 


RotateAnimation. The first parameter of applytransformation() is the progress time value of the animation, with a value range of [0.0F, 1.0F]. The second parameter transformation records the original data of deformation in a frame of the animation. This method is called during the display of each frame of the animation. 


In the process of flipping, in order to avoid the mirror effect of the image in the second half of the animation affecting the reading of the number, the flipping angle should be subtracted by 180 degrees. Code is

After the animation flips to half, the digital content should be updated. In order to know the flipping progress, an internal static interface class "interpolatedtimelistener" is designed in rotateanimation. The interface has only one method "interpolatedtime (float interpolatedtime)" to pass the animation progress to the monitoring initiator.

The Java code is as follows. Please implement the XML according to the rendering: 


ActRotate. java

RotateAnimation. java

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>