Before the animation begins, make a shape or a solid. Position it behind the text. Parent it to the text layer. Done.
Hi Dave - I tried that but it didn't work. I wonder if this is because the text layer has 'Animator' effects applied to it?
I'll keep playing around and see if I can do it.
If you know how to create an Expression (it's as simple as holding down the ALT key while clicking on a property's Stopwatch icon) then the answer lies in using the sourceRectAtTime Expression method.
Take a look here - https://www.momographics.co.uk/more-momo/2017/5/26/textbox-resize
Parenting only works with Transform properties (except Opacity). Animation created using Text Animator properties will not transfer over via Parenting.
I wonder if this is because the text layer has 'Animator' effects applied to it?
Yes, it is. To do what you want you would have to use the sourceRectAtTime() expression or simply animate the square manualyl to match.