Following code works for enter animation and exit animation as well, i do not want it to animate on exit. What am i doing wrong here. ?

        MyProfileFragment profileFragment = new MyProfileFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.content_frame, profileFragment);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            profileFragment.setEnterTransition(new Fade().setDuration(200));
            //profileFragment.setExitTransition(new Fade().setDuration(0));
        }

        ft.addToBackStack("profile");
        ft.commit();
1

There are 1 best solutions below

0
On

By default, the value passed into Fragment.setEnterTransition is reversed when that Fragment exits. To avoid this, you can assign null or another value to Fragment.setExitTransition.