Android Activity interface switch to add animation effects, Android activity

Source: Internet
Author: User

Android Activity interface switch to add animation effects, Android activity

OverridePendingTransition () is available after Android 2.0. There are two parameters, one being the exit entry of the previous activity,

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 pop-up screen.

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

This is not a good one, but also.

Fade in and out

Java code  
  1. OverridePendingTransition (Android. R. anim. fade_in, android. R. anim. fade_out );

 

Effect of sliding from left to right

Java code  
  1. OverridePendingTransition (Android. R. anim. slide_in_left, android. R. anim. slide_out_right );

 

Zoomin and zoomout are implemented, which is similar to the entry and exit effects of the iphone.

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

 

Create a 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: Ready Tx = "50% p" android: Ready ty = "50% p"
  7. Android: duration = "@ android: integer/config_mediumAnimTime"/>
  8. </Set>

 

Create a 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: Ready Tx = "50% p" android: Ready ty = "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>

 


How does android implement sliding switching between multiple activity interfaces?

Fiddingin
 
Android development, in the same activity, you can achieve the animation effect when switching the layout.

How to switch two la s

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.