zoukankan      html  css  js  c++  java
  • Activity 页面切换的效果

    Android 2.0之后有了overridePendingTransition(),其中里面两个参数,一个是前一个activity的退出两一个activity的进入,
         @Override 
          public   void   onCreate(Bundle    savedInstanceState)     { 
    
             super.onCreate(savedInstanceState); 
         
             setContentView(R.layout.SplashScreen); 
         
             new  Handler().postDelayed(new  Runnable()    { 
             @Override 
             public   void  run()     { 
              Intent  mainIntent    =  new   Intent(SplashScreen.this, 
                    AndroidNews.class); 
              SplashScreen.this.startActivity(mainIntent); 
              SplashScreen.this.finish(); 
         
              overridePendingTransition(R.anim.mainfadein, 
                                 R.anim.splashfadeout); 
              } 
              },  3000); 
    
           }         

    上面的代码只是闪屏的一部分。

    getWindow (). setWindowAnimations (  int  );

    这可没有上个好但是也可以实现。

    淡入淡出的效果:

    overridePendingTransition(Android.R.anim.fade_in,android.R.anim
    .fade_out); 

    由左向右滑入的效果:

    overridePendingTransition(Android.R.anim.slide_in_left,android.
    R.anim.slide_out_right);

    实现zoomin 和zoomout,即类似iphone的进入和退出时的效果:

    overridePendingTransition(R.anim.zoomin,  R.anim.zoomout);

    zoomin.xml 文件:

    <?xml  version="1.0"  encoding="utf-8"?>     
    <set xmlns:Android="http://schemas.android.com/apk/res/android"   
      Android:interpolator="@android:anim/decelerate_interpolator"> 
      <scale Android:fromXScale="2.0" android:toXScale="1.0"        Android:fromYScale="2.0" android:toYScale="1.0"        Android:pivotX="50%p" android:pivotY="50%p"        Android:duration="@android:integer/config_mediumAnimTime" /> </set>

    zoomout.xml 文件:

    <?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">     
    
        <scale  Android:fromXScale="1.0"  android:toXScale=".5"     
                Android:fromYScale="1.0"  android:toYScale=".5"     
                Android:pivotX="50%p"  android:pivotY="50%p"     
                Android:duration="@android:integer/config_mediumAnimTime"  />
         
        <alpha  Android:fromAlpha="1.0"  android:toAlpha="0"     
               Android:duration="@android:integer/config_mediumAnimTime"/>   
    </set>                                            
  • 相关阅读:
    CentOS7.0下Zabbix3.4至Zabbix4.0的升级步骤(Proxy)
    CentOS6.5下Zabbix3.0升级到4.0
    kubernetes相关概念
    更新OpenSSL
    fish 常用主题推荐
    [转] Adobe acrobat 破解教程
    [转]latex符号
    bank conflct 一句话总结
    Ubuntu 安装boost 库
    ubuntu 16.04安装nVidia显卡驱动和cuda/cudnn踩坑过程
  • 原文地址:https://www.cnblogs.com/rfheh/p/4166723.html
Copyright © 2011-2022 走看看