How to Reverse Fragment Animations on BackStack?

后端 未结 6 1442
日久生厌
日久生厌 2020-12-04 13:56

I thought the system would reverse animations on the backstack when the back button is pressed when using fragments using the following code:

FragmentManager         


        
6条回答
  •  攒了一身酷
    2020-12-04 14:31

    .setCustomAnimations(R.animator.fragment_fade_in,
            R.animator.fragment_fade_out,
            R.animator.fragment_fade_p_in,
            R.animator.fragment_fade_p_out)
    

    Replace the above with:

    mFragmentManager.beginTransaction()
        .setCustomAnimations(R.animator.fragment_fade_in,
                R.animator.fragment_fade_out,
                R.animator.fragment_fade_p_in,
                R.animator.fragment_fade_p_out)
        .replace(R.id.main_container, FragmentPlayerInfo.getInstance(data))
        .addToBackStack(FragmentPlayerInfo.TAG)
        .commit();
    

提交回复
热议问题