简体   繁体   中英

FragmentTransaction animation - show enter fragment above exit fragment

When you use are examined animation shift fragments (outgoing fragment has a longer duration than the animation comes fragment) faced with the fact that the fragment comes time animation falls under the outgoing fragment - I expected it to be animated over the outgoing fragment. Who knows how to achieve the desired effect it?

first fragment add:

fragmentManager.beginTransaction().add(R.id.frame_layout_fragments_container, new FragmentHome(), "home").commit();

replace fragment:

fragmentManager.beginTransaction().setCustomAnimations(R.anim.forward_show, R.anim.forward_hide, R.anim.back_show, R.anim.back_hide).replace(R.id.frame_layout_fragments_container, fragment, fragmentName).commit();

simple illustrations

now I have: 在此输入图像描述

what I need: 在此输入图像描述

something like Zoom-out page transformer?? http://developer.android.com/training/animation/screen-slide.html

I think you could try the following approach as a work around.

fragmentTr.setCustomAnimations(enter, exit);
fragmentTr.hide(currentFragment);
fragmentTr.add(containerId, newFragment, "aTag");
fragmentTr.show(newFragment);
fragmentTr.commit();

Do not use replace(). I tried the above approach, and it worked. Hope this helps.

ViewCompat.setTranslation(getView, 100.f);

寻找https://stackoverflow.com/a/33816251/6642400

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