Making animations with transitions

To animate transactions between fragments, it's needed to assign some animation resources to the transaction instance. As you remember, after we begin the fragment transaction, we get one transaction instance. We can then access this instance and execute the method as follows:

  • setCustomAnimations (int enter, int exit, int popEnter, int popExit)

Or, we can use this method:

  • setCustomAnimations (int enter, int exit)

Here, each parameter represents the animation used in this transaction. We can define our own animation resources or use one of the predefined ones:

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.