ScrollContainer does not expand?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LastAngryMan
:warning: Old Version Published before Godot 3 was released.

I’m learning godot GUI and currently trying to implement a scrolling list with the ScrollContainer. However, no matter what I do, I can’t get the ScrollContainer to expand and show child elements - even if I resize in the editor, when I run the game the items within are not visible. If I remove the ScrollContainer, and just have a VBoxContainer with overflowing elements, everything displays OK. I’ve attached some screenshots that show the scene tree and the resulting game:

What am I missing? I’m not sure if I should be setting the Size, MinSize or margin properties in the inspector? Or should the ScrollContainer work all this out on it’s own?

:bust_in_silhouette: Reply From: gonzo191

Setting up the scroll container is a bit tricky the first time you use it. Here’s how I was able to get it working.

Node Layout

ScrollContainer
	VBoxContainer
		Container

ScrollContainer

  • Set the direction it will scroll i.e. horizontal, vertical
  • Set its default size
  • Set the size flags to be both Fill

VBoxContainer

  • Set its default size ensuring its height is greater than the scroll container’s height (adjust values to compensate for the scrollbar(s))
  • Set its minimum size as the same default size values
  • Set the size flags to be both Expand and Fill

Container (Any control node that represents the scrollable items)

  • Set the size flags to be both Expand and Fill

Hopefully this helps.