Once you choose the category — text description flows and gets set as toolbar title

Overall Intention is to animate the textsize and text padding change of the shared textview in the CategoryActivity and QuizActivity. This is achived using TextSharedElementCallback and TextResizeTransition

So lets see first about when the overridden methods in the TextSharedElementCallback() are called.

onSharedElementStart()

=> In Activity Transitions, onSharedElementStart is called immediately before capturing the start of the shared element state on enter and reenter transitions and immediately before capturing the end of the shared element state for exit and return transitions.

onSharedElementEnd()

=> In Activity Transitions, onSharedElementEnd is called immediately before capturing the end of the shared element state on enter and reenter transitions and immediately before capturing the start of the shared element state for exit and return transitions

Please refer to https://developer.android.com/reference/android/app/SharedElementCallback

This is how the shared element transition happens

In the constructor of TextSharedElementCallback, inital size and padding of the textview is passed [ That is the value present in CategoryActivity ] Now when the TextSharedElementCallback -> OnSharedElementStart is called, the measured value of textview size and padding is stored in local variables and the textSize and padding has been set to the one calculated in #1 [ This becomes initial state ] These values are then passed to custom transition defined in TextResizeTransition

4. Now when the TextSharedElementCallback -> OnSharedElementEnd is called, the stored values in #2 are set again on the textView which are the final values in the QuizActivity

5. These values are then passed to custom transition defined in TextResizeTransition

6. The captured values in #3 and #5 are then animated in the custom transition defined in TextResizeTransition by overriding createAnimator()