I can use FragmentTransaction#setCustomAnimation(int, int)
method to define the animations when changing Fragments as described in this answer. However, this approach is limited to animations defined in XML files.
Is there a way to use programmatically defined animations when switching between Fragments?