How to Spread UI Element in Canvas in Unity?

Hello there~

I am currently following this tutorial: Unity 5 Tutorial: Turn Based Battle System #03 - User Interface - YouTube.

How can I “spread” GameObject inside the HeroBar evenly?

alt text

Let say if I set the Text to be 50% width of its parent, then the ProgressBG should follow up to fill the 50%. If I set the Text to be 60% width, then the ProgressBG should follow up to fill the 40% and so on.

How can I achieve this from Unity UI or from codes?

Right now, it is just uncontrolled mess even the ProgressBG can go outside the parent GameObject.

Sorry… I got the answer. I am using Horizontal and Vertical Layout Group to achieve what I want.