Disable Transition Animation Between Activities

2019-03-14 08:17发布

问题:

I am calling an Activity B from Activity A, which contains a Video View using the following code :

Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);

I am using Intent.FLAG_ACTIVITY_NO_ANIMATION to avoid transition animation while new activity is being called. But its not working for me and a black screen is coming while the transition. Is there any way to avoid this transition animation and black screen, so that the user will not come to know that the video view is being called in a new screen?

回答1:

if you want to do it for all activities then do it in this way:

switching activities without animation

Just assign style with no animation to each activity in manifest.

Or through code do it in this way:

Disable activity slide-in animation when launching new activity?



回答2:

Try calling:

Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);
overridePendingTransition(0,0); //0 for no animation