How can I animate the exanpansion a UI container to the height of it's Margin Container Parent in code

Godot Version

4.3

Question

I have a UI element I’m trying to program which involves pressing a button and having another UI element that animates to fill the full height of the Margin Container parent it’s enclosed within. How would I do this in code without just hard-coding the y height values? Is there even a way to do that?

what are the Control nodes you are using?

animations for UI are done through Tweens. the rest depends on whether your UI is well though out.

that said, all elements of a Control node can be changed through code and will move to fill the entire area, but to do it slowly, it depends on what it looks like and in some cases it could be a better idea to override the draw function to do a custom drawing of the elements. again, this depends on what you are trying to do.

that is NOT how margin containers work. you need a different Control node. margin containers are for adding a space around a node, and as all containers they change size automatically to fit their content or can force the content to fit within the limits, so long as there are no elements with min size or aspect ratio to maintain.