简体   繁体   中英

Android 5.0 Slide Animation Flashing fragment

I'm looking to use the Slide Transition class added in the Android SDK 21. Currently I have this code to replace my fragment:

    Fragment fragment = getFragment(fragmentManager);

    Slide slide = new Slide(Gravity.RIGHT);
    fragment.setEnterTransition(slide);


    fragmentManager.beginTrSlideansaction()
        .replace(R.id.content, fragment, getKey())
        .commit();

The Slide animation works for the fragment coming into view, but the fragment that currently existed in the R.id.content container flashes white instead of sliding off the opposite side.

Any ideas what I may be missing?

So it turns out that I was mistaken in thinking that this Slide animation handles the exit transition. The white flash happens because the old fragment is removed instantly and the new one slides in from the right side.

To get the full animation I just did it the old way using XML Animations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM