Fade in Activity from previous Activity in Android

后端 未结 2 1472
生来不讨喜
生来不讨喜 2020-12-29 07:01

I am currently working on an Android app and I am having some issues with my splash activity. I want my main activity to fade in from my splash activity, not from a black sc

2条回答
  •  醉酒成梦
    2020-12-29 07:36

    I'd recommend against a classic crossfade, but rather show the new Activity without an animation and just fade out the current Activity. This looks & feels much cleaner and resolves some minor issues where you can see the launcher/underlying app when you open the app from the background while the animation is starting.

    my_splash_fade_out.xml

    
    
    
    

    I'm adding a startOffset here to give the newly created Activity a bit off a head start, as it is rather heavy.

    MySplashActivity.java

    ...
    startActivity( ... );
    finish();
    overridePendingTransition( 0, R.anim.screen_splash_fade_out );
    

    Preview

提交回复
热议问题