Android Activity Toggle Animation Overridependingtransition

Source: Internet
Author: User

Activity is able to use the fade in, swipe, zoom, and other dynamic effects when switching or exiting. The method overridependingtransition is used, which can be directly called in the activity.

overridependingtransition (r.anim.zoomin, R.anim.zoomout) The first parameter is the de facto animation, and the second is the end animation. This method is called after startactivity () or Finish (), which is called when the animation is toggled or exited.

Intent phoneintent=new Intent (Intent.action_pick,contactscontract.contacts.content_uri); Startactivityforresult ( Phoneintent, 1); Overridependingtransition (R.anim.zoomin, r.anim.zoomout);
1, Fade effect

The fade-in effect of Android's package has already been provided, Overridependingtransition (Android. R.anim.fade_in, Android. R.anim.fade_out), using the system's own fade-in effect. You can also use your own defined in and out animations, if fade in fade_in, fade out to fade_out.

Fade_in.xml:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <alpha        android:duration= "android:fromalpha="        0.0 "        android:toalpha=" 1.0 "/>< /set>
Fade_out:
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <alpha        android:duration= "android:fromalpha="        1.0 "        android:toalpha=" 0.0 "/></ Set>
android:duration= "1500" sets the animated continuous event, and the change in transparency of the other settings achieves the fade in effect. The Overridependingtransition (r.anim.fade_in, r.anim.fade_out) is called in the activity, and the fade-in effect is achieved.

2, left and right slide effect

The effect of sliding left and right on Android is also provided, Overridependingtransition (Android. R.anim.slide_in_left, Android. R.anim.slide_out_right); The system uses a left-to-right swipe of the system, which now only supports the effect of this one-left slide. The same can also be achieved by using your own definition animation to move from left to right to the same time can also be used to swipe from right to left.

1) swipe from left to right

Sliding two animations are slide_left_in and slide_right_out, respectively.

Slide_left_in:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <translate        android:duration= "android:fromxdelta="        -100.0%p "        android:toxdelta=" 0.0 " /></set>
Slide_right_out:
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <translate        android:duration= "android:fromxdelta="        0.0 "android:toxdelta=" 100.0%p "        / ></set>
Overridependingtransition (r.anim.slide_left_in, r.anim.slide_right_out) is invoked in the activity, and the effect of sliding from left to right is achieved.

2) swipe from right to left

The sliding two animations are slide_right_in and slide_left_out respectively.

Slide_right_in:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <translate        android:duration= "android:fromxdelta="        100.0%p "        android:toxdelta=" 0.0 "/ ></set>
slide_left_out:
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <translate        android:duration= "android:fromxdelta="        0.0 "        android:toxdelta=" -100.0%p " /></set>
in activity which calls overridependingtransition (r.anim.slide_right_in, r.anim.slide_left_out); The effect of sliding from right to left is achieved.

3, Zoom effect

There is no animation in the Android package that can only define the animation itself, and the animation itself is zoomin and zoomout.

ZoomIn:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" Android:interpolator= "@android: Anim/decelerate_interpolator" ><scaleandroid:duration= "@android: integer/ Config_mediumanimtime "android:fromxscale=" 2.0 "android:fromyscale=" 2.0 "android:pivotx=" 50%p "android:pivotY=" 50% P "android:toxscale=" 1.0 "android:toyscale=" 1.0 "/></set>
Zoomout:
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" Android:interpolator= "@android: Anim/decelerate_interpolator" android:zadjustment= "Top" ><scaleandroid: Duration= "@android: Integer/config_mediumanimtime" android:fromxscale= "1.0" android:fromyscale= "1.0" Android: pivotx= "50%p" android:pivoty= "50%p" android:toxscale= ". 5" android:toyscale= ". 5"/><alphaandroid:duration= "@ Android:integer/config_mediumanimtime "Android:fromalpha=" 1.0 "android:toalpha=" 0 "/></set>
In activity where Overridependingtransition (R.anim.zoomin, R.anim.zoomout) is able to achieve a similar zoom effect.



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.