androidmaterial-designshared-element-transition

Blinking screen on image transition between activities


I implemented an image transition between two activities using the new shared elements from lollipop. It's working but I get a weird white blinking on the entire screen during the transition and I can't find how to get rid of it. Here is an example: Status bar also blinking

Here is how the second activity is launched

public static void launch(
            @NonNull Activity activity, @NonNull View transitionView, Game game) {
        ActivityOptionsCompat options =
                ActivityOptionsCompat.makeSceneTransitionAnimation(
                        activity, transitionView, game.gameFullId);
        Intent intent = new Intent(activity, ListImportationLoginActivity.class);
        intent.putExtra(INTENT_EXTRA_GAME, retailer);
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    }

Then in onCreate:

ViewCompat.setTransitionName(mLogoView, mGame.gameFullId);  

And the theme file:

<resources>
    <style name="Theme.MyApp.NoActionBar" parent="Theme.MyApp.NoActionBar.Base">
        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">true</item>
        <item name="android:windowAllowReturnTransitionOverlap">true</item>
        <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
        <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
    </style>
</resources>  

Thanks for your help


Solution

  • On the exiting activity, call getWindow().setExitTransition(null);

    On the entering activity, call getWindow().setEnterTransition(null);

    It will prevent the fade out of the exiting activity and the fade in of the entering activity, which removes the apparent blinking effect.