How to center the horizontal scroll viewer ui elements to be in the center by default by code?

i want it to be elastic and when I drag the images elements inside it will return to the left but in fact to return to the center. now when I’m running the game if there are only 3 elements for example they are not in the center they are too left. and I want them to start in the center.

not sure how to do it and if I should do it by code or in the editor.

the viewport as it is now in runtime. it’s position more ot the left side:

I can drag the viewport on the red and put it more or less manual in the center. but I want it to be automatic in the center.

this screenshot is after dragging the red with the mouse: and this is how I want it to be automatic, when running the game that it will be in the center.

this is the settings of the content:

You can change the Layout to start filling from center. This may be part of the issue.

You can also manipulate this property to change the scroll position yourself:

Pay attention to the units: it is normalized to the full potentially-varying width of the content area.

There’s also a TON of interesting extensions in this package and they might be of some use: