Cannot get text+image always centered

Hi,

I am trying to resolve simple task - show coins amount (text) with the coin image next to it. Amount can be changed, so this group should center itself on the screen.

I’ve nearly got what I want, but it not always centered correctly. When amount grows larger then center shifts to the left, but when amount shrinks - center goes back to normal:
https://media.giphy.com/media/3oKGziNPABhVWzg8I8/giphy.gif

Here is how I set it up:

  1. Parent - Horizontal Group
  2. Child 1 - Text
  3. Child 2 - Image

Parent:
100693-horizontal-group.png
Child1:


Child 2: Imgur: The magic of the Internet

How can I achive my task without this “jumping” text effect?
Thanks

I resolved this problem by rebuilding layout each time when I set new text.

[SerializeField]
RectTransform coinsLayout;

LayoutRebuilder.ForceRebuildLayoutImmediate(coinsLayout);