Android Activity Interface Toggle Add animated Effects

Source: Internet
Author: User

After Android 2.0 there is a overridependingtransition (), of which two parameters, one is the previous activity's exit 21 activity entry,

Java code
  1. @Override
  2. public void OnCreate (Bundle savedinstancestate) {
  3. super.oncreate (savedinstancestate);
  4. Setcontentview (R.layout.splashscreen);
  5. new Handler (). postdelayed (new Runnable () {
  6. @Override
  7. public Void Run () {
  8. Intent mainintent = new Intent (SplashScreen. This, androidnews.   class);
  9. SplashScreen.   this.startactivity (mainintent);
  10. SplashScreen.   This.finish ();
  11. Overridependingtransition (R.anim.mainfadein,
  12. R.anim.splashfadeout);
  13. }
  14. }, 3000);
  15. }

The above code is only part of the splash screen.

Java code
    1. GetWindow ().    Setwindowanimations ( int);

It's not as good as it might be.

Achieve fade-out effects

Java code
    1. Overridependingtransition (android.r.anim.fade_in,android. R.anim.fade_out);

Effects that slide from left to right

Java code
    1. Overridependingtransition (android.r.anim.slide_in_left,android. R.anim.slide_out_right);

Implement ZoomIn and Zoomout, which are similar to the iphone's entry and exit effects

Java code
    1. Overridependingtransition (R.anim.zoomin, r.anim.zoomout);

New Zoomin.xml File

XML code
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:interpolator="@android: Anim/decelerate_interpolator">
  4. <scale android:fromxscale= "2.0" android:toxscale="1.0 "
  5. android:fromyscale= "2.0" android:toyscale="1.0 "
  6. android:pivotx= "50%p" android:pivoty="50%p "
  7. android:duration="@android: Integer/config_mediumanimtime" />
  8. </Set>

New Zoomout.xml File

XML code
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:interpolator="@android: Anim/decelerate_interpolator"
  4. android:zadjustment="Top">
  5. <scale android:fromxscale="1.0" android:toxscale= ". 5"
  6. android:fromyscale= "1.0" android:toyscale= ". 5"
  7. android:pivotx= "50%p" android:pivoty="50%p "
  8. android:duration="@android: Integer/config_mediumanimtime" />
  9. <Alpha android:fromalpha= "1.0" android:toalpha="0"
  10. android:duration="@android: Integer/config_mediumanimtime"/>
  11. </Set>

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.