Animations in Android

Source: Internet
Author: User

Android

The following 4 animation effects are available:

1. Alphaanimation Transparency Animation effect

2. Scaleanimation Zoom Animation effect

3. Translateanimation Displacement Animation effect

4. Rotateanimation Rotation animation effect

Today, we use displacement animations to implement the effects of the switching interface:

Translateanimation includes:

Float Fromxdelta The difference from the current view x-coordinate of the starting point of the animation

Float Toxdelta The difference in the end of the animation from the current view x-coordinate

Float Fromydelta The difference between the starting point of the animation and the current view y-coordinate

Float Toydelta The difference between the starting point of the animation and the current view y-coordinate

Usage

Animation.setduration (long Durationmillis);//Set animation duration

Animation.setrepeatcount (int i);//Set the number of repetitions

Animation.setrepeatmode (animation.reverse);//Set Reverse direction execution

Android:duration: The time the animation was run: the document was originally

  • android:duration

  • int. The time in milliseconds of the animation. 300MS is the default.

  • That is, the default is 300 milliseconds

  • Android:repeatcount: Defines when the animation repeats

    Demo: Requirements, in the Android Setup Wizard, you may need to go to the next page, return to the previous page,

    And then we're going to make it.

    Slide from left to right

    Translate_in.xml
    <?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "Android:fromxdelta=" 100% "android:fromydelta=" 0 "android:toxdelta=" 0 "Andro Id:toydelta= "0" ></translate>
    Translate_out.xml
    <?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "android:fromxdelta=" 0 "android:fromydelta=" 0 "android:toxdelta=" -100% "Android Oid:toydelta= "0" ></translate>
    How to use
    /* Requires execution of */overridependingtransition (r.anim.translate_in, r.anim.translate_out) behind the finish () or StartActivity method;
    Swipe from right to left:
    Translate_precede_in.xml
    <?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "Android:fromxdelta=" -100% "android:fromydelta=" 0 "android:toxdelta=" 0 "Android Oid:toydelta= "0" ></translate>
    Translate_precede_in.xml
    <?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "android:fromxdelta=" 0 "android:fromydelta=" 0 "android:toxdelta=" 100% "Andro Id:toydelta= "0" ></translate>
    How to use
    Overridependingtransition (r.anim.translate_precede_in, r.anim.translate_precede_out);


Animations in Android

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.