Rotate animation for Android details

Source: Internet
Author: User


Flip Animation for Android:


The recent project has used a small animation, so that the object to achieve a certain 3D rotation effect, is now recorded as follows:


public class Flipanimation extends Animation {private Camera mcamera;    Private View Mfromview;    Private View Mtoview;    private float Mcenterx;    private float mcentery;    Private Boolean mforward = true;     /** * Creates a 3D flip animation between.     * * @param fromview First view in the transition.     * @param toview Second view in the transition.        */Public Flipanimation (view Fromview, view toview) {Mfromview = Fromview;        Mtoview = Toview;        Setduration (700);        Setfillafter (FALSE);    Setinterpolator (New Acceleratedecelerateinterpolator ());        } public void reverse () {Mforward = false;        View SwitchView = Mtoview;        Mtoview = Mfromview;    Mfromview = SwitchView; } @Override public void Initialize (int width, int height, int parentwidth, int parentheight) {Super.initiali        Ze (width, height, parentwidth, parentheight);        Mcenterx = WIDTH/2;    Mcentery = HEIGHT/2;    Mcamera = new Camera (); } @Override protected void applytransformation (float interpolatedtime, transformation t) {final double Radia        NS = Math.PI * INTERPOLATEDTIME;        float degrees = (float) (180.0 * radians/math.pi);            if (interpolatedtime >= 0.5f) {degrees-= 180.F;            Mfromview.setvisibility (View.gone);        Mtoview.setvisibility (view.visible);        } if (Mforward) {degrees =-degrees;        } final Matrix Matrix = T.getmatrix ();        Mcamera.save ();        Mcamera.rotatey (degrees);        Mcamera.getmatrix (matrix);        Mcamera.restore ();        Matrix.pretranslate (-mcenterx,-mcentery);    Matrix.posttranslate (Mcenterx, mcentery); }}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.