What is the difference between I / O and popEnter / popExit, and what transaction animation will work on the pop stack

In setCustomAnimations (), animation requires four resource identifiers. Do not quite understand them. If someone gave a clearer picture of this, it would be helpful if you could explain.

Say by adding fragment A to the place and back.

FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.holder, fragA, FragmentA.FRAGMENT_NAME);
        ft.addToBackStack(FragmentA.FRAGMENT_NAME);
        ft.setCustomAnimations(R.anim.slide_in_from_bottom, R.anim.slide_in_from_top, R.anim.slide_in_from_left, R.anim.slide_in_from_right);
        ft.show(frag);
        ft.commit();

And replacing fragment B:

FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.holder, fragB, FragmentB.FRAGMENT_NAME);
        ft.addToBackStack(FragmentB.FRAGMENT_NAME);
        ft.setCustomAnimations(R.anim.slide_in_from_bottom, R.anim.slide_in_from_top, R.anim.slide_in_from_left, R.anim.slide_in_from_right);
        ft.show(frag);
        ft.commit();

next time if popstack () is done

fm.popBackStackImmediate(FragmentB.FRAGMENT_NAME,
                                FragmentManager.POP_BACK_STACK_INCLUSIVE);

What kind of transactional animation will it perform?

/**
 * Set specific animation resources to run for the fragments that are
 * entering and exiting in this transaction. The <code>popEnter</code>
 * and <code>popExit</code> animations will be played for enter/exit
 * operations specifically when popping the back stack.
 */
public abstract FragmentTransaction setCustomAnimations(@AnimRes int enter,
        @AnimRes int exit, @AnimRes int popEnter, @AnimRes int popExit);
+4
source share
1 answer

Let the simple case begin:

Replace fragment A with fragment B (your second code fragment)

  • Fragment B starts the animation
  • Fragment A launches exit animation

""

  • B popExit
  • A popEnter

, .

, . :

  • ( 0), A. :

    • B popExit ( )
    • 0 popEnter ( )
  • , A , , . :

    • B popExit ( )
    • popEnter, .
+10

Source: https://habr.com/ru/post/1662352/


All Articles