Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I avoid fade to black on Activity transition?

I am creating an app where almost all of the animations are fades. For a few of the pages, elements will dynamically appear / disappear off the screen, and all the fading is quite natural (white background for the app). However, when I transition between Activities, the app fades to black before fading back into the next Activity. Since all the backgrounds are the same color, I was wondering if there was a way to avoid this, so that the background constantly remains the same color, and only the elements on it seem to fade as the app state changes.

I use the following code for my transitions:

Intent intent = new Intent(this, NextActivity.class);
startActivity(intent);
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

Sometimes without the finish(), as necessary. I've looked into this briefly, and the problem other people seem to have is with a long lasting black screen that is associated with NextActivity having a computationally intensive onCreate(). This is not the case for me. The onCreate() methods do little in terms of computing, merely define some listeners. All intense logic is offloaded to threads. It is quite literally a UI problem for me that I am trying to find a work around for.

like image 853
mike Avatar asked Oct 20 '22 20:10

mike


1 Answers

I found that setting android:zAdjustment="top" on the fade out animation made the black screen in-between go away.

See sample XML in this answer: https://stackoverflow.com/a/9150436/1481500

like image 105
kos Avatar answered Oct 22 '22 08:10

kos