I have a label and a progress bar in a GridContainer and this GridContainer is inside a HBoxContainer.
How can I vertically center all items in this GridContainer?
Badoglio Put a HBoxContainer inside GridContainer. You did the opposite. So:
GridContainer
--- HBoxContainer
------ Label
--- ProgressBar
Badoglio Additionally contain the label within vertically expanded or center shrinked HBoxContainer.
Tedmann Thanks for help. I tried to contain the GridContainer with a new vertically expanded or center shrinked HBoxContainer but nothing happens. Here's how my scene tree look like,
You need to set GridContainer column to 1 for it to stack vertically.
You can add spacers. Just add a control node above and below what you want to center and set them as expand fill.
This video from GDQuest might help you.
By the way, you didn't give which Godot version you're using, 3.5 and 4.0 doesn't not manage containers the same way, and AFAIK, we need to give a custom minimum size at one point because containers are unable to calculate one themselves, even and especially when they have some content which have a defined size (label or texture for instance.)
Badoglio Put a HBoxContainer inside GridContainer. You did the opposite. So:
GridContainer
--- HBoxContainer
------ Label
--- ProgressBar
Bite Yes but what I need is for both items to vertically center not vertically stack.
Limitless Yes this work. Thanks!
Tedmann Yes this work well and the progress bar has to be inside a HBoxContainer too. Thanks!
© 2022 - 2024 — McMap. All rights reserved.