'Fragment add exit custom animation not working working when fragment is Added Android

The custom exit animation works for replace but not for add

getNavFragment()
        .childFragmentManager
        .beginTransaction()
        .setCustomAnimations(
            enter,
            exit,
            popEnter,
            popExit
        )
        .add(R.id.fl_fragment_container, fragment, tag)
        .setReorderingAllowed(true)
        .apply {
            if (shouldAddToBackStack)
                addToBackStack(tag)
        }
        .commit()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source