I have set up a scrolling frame with a list layout and some padding. As this screenshot shows, the content very clearly goes outside the frame when I turn off ClipsDescendants:
Now, I add a script which sets the canvas size based on the contents of the list layout:
local TweenService = game:GetService("TweenService")
local scroll = script.Parent.Scroll
local layout = scroll:FindFirstChildWhichIsA "UIGridStyleLayout"
if not layout then return end
local function resize()
local size = layout.AbsoluteContentSize
scroll.CanvasSize = UDim2.new(0, size.X, 0, size.Y)
end
resize()
layout:GetPropertyChangedSignal "AbsoluteContentSize":Connect(resize)
The expected result is that the scrolling frame would show the scrollbar and be scrollable both via dragging the scrollbar and by scrolling the mouse wheel:
However, the actual result is a bit weirder, as the scrollbar is not visible and I cannot scroll with the mouse wheel, and I can’t drag where the scrollbar would be either. It does still reserve space for the scrollbar however:
The AbsoluteSize of the scrolling frame as reported by Studio is 640x430.
The AbsoluteContentSize of the list layout is 610x436.
The CanvasSize set by the local script above is also 610x436.
The scrolling does however start working when the canvas size becomes significantly different from the scrolling frame size.
Here’s a model containing the problematic frame: scrollingframe.rbxm (8.6 KB)
The scrollbar will only show up when the CanvasSize’s height is bigger than the frame, however when counting the content size you’re getting the offset which isn’t as big as the frame.
Set the CanvasSize Y scale to 1 and it should show up.
I’m not at my PC to test this, but wouldn’t this just make the canvas one screen taller, thus introducing a ton of whitespace under the content? This is what the wiki says about it:
The UDim2 is calculated using the parent gui’s size, similar to the regular Size property on gui objects.
I would prefer tight sizing if possible; if I’m wrong then please do correct me
This will add 66 offset (will be different if you change the padding) to your final size because UIListLayout’s AbsoluteContentSize property does not take padding into account.
This will make it very tightly sized, and does work for me. (at least on my computer)
FWIW, this behavior is intentional - AbsoluteContentSize deliberately does not include the padding imposed by a UIPadding instance. The correct solution is to factor the padding in like above.
The scrolling frame should not be reserving space for the vertical scrollbar. I’ll look into this one.