James andresakis
James andresakis

Reputation: 5415

Android - Previous activity goes black during transition

I have an activity where I use overridePendingTransition to set a custom animation which works fine on the first try but for some reason when I go back to the previous activity the screen turns black on the second try. Ive searched around but cant come up with a solution to fix it yet. Heres the custom animation

<?xml version="1.0" encoding="utf-8"?>
<set
android:interpolator="@android:anim/fade_out"
xmlns:android="http://schemas.android.com/apk/res/android">
<translate 
    android:fromXDelta="0%"
    android:toXDelta="0%"
    android:fromYDelta="0%"
    android:duration="4000"
    />

</set>

I call the overridePendingTransition in a button click like this

OnClickListener click = new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent panIntent = new Intent(SActivity.this, S2Activity.class);
                panIntent.putExtra(S2Activity.EXTRA_TENANT_INFO, panics.get(position).toString());
                panIntent.putExtra("fromHistory", 0);
                panIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(panIntent);
                overridePendingTransition(R.anim.bounce, R.anim.do_nothing);
            }
        };

The behavior Im looking for is for the new activity to scroll in from the right to the left and for the previous one to stay there in the background without the screen going black for a second. Ive played with the duration and other stuff as well.

UPDATE:

Even after moving all my initialization of bitmaps and resources to asynctasks and moving things to the onResume the previous activity still goes black as the new activity moves into view. Ive tried setting the theme but that doesnt have any effect either.

Upvotes: 2

Views: 2158

Answers (1)

James andresakis
James andresakis

Reputation: 5415

I fixed this finally by creating a theme that uses android:style/Theme.Translucent as a parent along with the other code that I posted before. My theme looks like this:

<style name="InvisibleBackgroundTheme" parent="@android:style/Theme.Translucent">
    <item name="android:windowActionBar">true</item>
</style>

I added everything else in there as well to keep the theme the same through out my app.

Upvotes: 1

Related Questions