android activity转场动画(不兼容5.0一下)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shb2058/article/details/76066556

四种启动方式分别对应:普通的启动方式(即startActivity)、explode、slide和fade;

使用的方法如下:

对于startActivity的设置时相同的:

  startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MainActivity.this).toBundle());

对于跳转到的页面的设置,注意:必须在setContentView之前进行方式的设置:

   if (getIntent().getStringExtra("type").equals("1")) {
            getWindow().setEnterTransition(new Explode());
        } else if (getIntent().getStringExtra("type").equals("2")) {
            getWindow().setEnterTransition(new Slide());
        } else if (getIntent().getStringExtra("type").equals("3")) {
            getWindow().setEnterTransition(new Fade());
        }else {

        }
        setContentView(R.layout.activity_two);


猜你喜欢

转载自blog.csdn.net/shb2058/article/details/76066556