zoukankan      html  css  js  c++  java
  • overridePendingTransition 页面转换动画

    在startActivity后,调用overridePendingTransition方法,例如,
    一)实现淡入淡出的效果如下:

    startActivity(new Intent(SplashActivity.this, MainActivity.class));

    SplashActivity.this.finish();

    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的进入和退出时的效果

    在res目录下新建文件夹anim,然后在anim下新建两个xml,默认选项不用更改,分别命名为zoomin.xml和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" >
    
      <scale
    
            android: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>
    
    <?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: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" />
    
        <alpha
    
            android:duration="@android:integer/config_mediumAnimTime"
    
            android:fromAlpha="1.0"
    
            android:toAlpha="0" />
    
    </set>
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import hgy.test.PendingTransition.R;
    
    public class MainActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            new Handler().postDelayed(new Runnable(){
    
                @Override
                public void run() {
                    Intent mainIntemt = new Intent(MainActivity.this,AndroidNews.class);
                    MainActivity.this.startActivity(mainIntemt);
                    MainActivity.this.finish();
                    //overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
                    
                    //实现淡入浅出的效果
                    overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
                   
                    //由左向右滑入的效果
                    //overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
                    
                    //实现zoommin 和 zoomout,即类似iphone的进入和退出时的效果
                    //overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
                }
                
            },3000);
        }
    }
  • 相关阅读:
    Ubuntu apt-get "Hash Sum mismatch" 问题解决方法
    模型压缩相关工作
    bn两个参数的计算以及layer norm、instance norm、group norm
    cascade rcnn论文总结
    c++ 堆和栈以及区别
    c++ 浅拷贝和深拷贝 指针和引用的区别 malloc(free)和new(delete)的区别 重载重写重定义
    c++ 多态,虚函数、重载函数、模版函数
    c++问题整理
    repulsion-loss
    smooth l1
  • 原文地址:https://www.cnblogs.com/622698abc/p/3185556.html
Copyright © 2011-2022 走看看