The previous introduction of the use of Android's own control, sliding page making effect, now we use code to achieve some sliding page animation effect.
Animation animations are implemented in two ways: Frame animation (Frame-by-frame animation) and motion tweens (tweened animation)
This example implements the 3D paging effect by inheriting animation custom Rotate3d. The effect chart is as follows:
1, Rotate3d (Animation)
First, customize the animation 3D animation class Rotate3d
public class Rotate3d extends Animation {private float fromdegree; Rotation starting angle private float todegree; Rotary Termination angle private float Mcenterx; Rotary Center x private float Mcentery;
Rotary Center y private Camera Mcamera; Public Rotate3d (float fromdegree, float todegree, float centerx, float centery) {this.fromdegree = Fromdegre
E
This.todegree = Todegree;
This.mcenterx = CenterX;
This.mcentery = CenterY;
@Override public void Initialize (int width, int height, int parentwidth, int parentheight) {
Super.initialize (width, height, parentwidth, parentheight);
Mcamera = new Camera (); @Override protected void applytransformation (float interpolatedtime, transformation t) {fin
Al float fromdegree = fromdegree; Float degrees = fromdegree + (todegree-fromdegree) * interpolatedtiMe
Rotation angle (angle) Final float CenterX = Mcenterx;
Final float centery = mcentery;
Final Matrix matrix = T.getmatrix ();
if (degrees <= -76.0f) {degrees = -90.0f;
Mcamera.save (); Mcamera.rotatey (degrees);
Rotating Mcamera.getmatrix (matrix);
Mcamera.restore ();
else if (degrees >= 76.0f) {degrees = 90.0f;
Mcamera.save ();
Mcamera.rotatey (degrees);
Mcamera.getmatrix (matrix);
Mcamera.restore ();
else {mcamera.save (); Mcamera.translate (0, 0, CenterX);
Displacement x mcamera.rotatey (degrees);
Mcamera.translate (0, 0,-centerx);
Mcamera.getmatrix (matrix);
Mcamera.restore (); } matrix.pretranslate (-centerx,-ceNtery);
Matrix.posttranslate (CenterX, centery); }
}