Android Activity Animation Call mode

Source: Internet
Author: User

Problem scenario: How do I get the activity to enter from the lower left corner and then press one of the buttons to exit to the lower left corner?

1. How animations are invoked.

There are 2 different ways. One is to specify the activity's theme in the XML file, and the second is to call overridependingtransition (int enteranim, int exitanim) after the startactivity and finish functions;

Since the activity's theme in my code has been specified, the second method is selected

2. Animations.

Using two animations, the key code specified in the lower left corner is android:pivotx=15%, android:pivoty=95%.

The code is as follows:

 activity into animation

<Setxmlns:android= "Http://schemas.android.com/apk/res/android"> <Alphaandroid:duration= "+"Android:fromalpha= "0"Android:toalpha= "1.0" /> < Scaleandroid:duration= "+"Android:fromxscale= "0"Android:fromyscale= "0"Android:pivotx= "15%"Android:pivoty= "95%"Android:toxscale= "1.0"Android:toyscale= "1.0" /></Set>
 activity exit animation

<Setxmlns:android= "Http://schemas.android.com/apk/res/android"> <Alphaandroid:duration= "+"Android:fromalpha= "1.0"Android:toalpha= "0" /> < Scaleandroid:duration= "+"Android:fromxscale= "1.0"Android:fromyscale= "1.0"Android:pivotx= "15%"Android:pivoty= "95%"Android:toxscale= "0"Android:toyscale= "0" /></Set>

3. Attention Points

overridependingtransition (int enteranim, int exitanim) was called after StartActivity, and no animation was found when exiting. The workaround is to also call overridependingtransition (int enteranim, int exitanim) after the finish function.

Repeated calls two times, feeling as if they were assigned to enter the animation and exit animation.


  

Android Activity Animation Call mode

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.