As a developer it is currently too difficult to create scalable UI when using ScrollingFrame instances that include padding.
Currently, when using any ‘Padding’ properties in UI layout instances - such as UIListLayout.Padding
or UIPadding.Padding...
- the Padding.Scale
property uses the ScrollingFrame’s AbsoluteCanvasSize property as its reference rather than their AbsoluteSize property. This causes a few annoying problems.
- When changing the canvas size of the ScrollingFrame, the elements inside the ScrollingFrame will also shift position if
Padding.Scale
is used in any UI layout instances. Below is a video of a ScrollingFrame with a UIPadding and UIListLayout inside of it, both usingPadding.Scale
. When the AbsoluteContentSize of the ScrollingFrame changes, I run code to ‘fit’ the CanvasSize to become equal to the AbsoluteContentSize. But when I start adding more Frames to the ScrollingFrame, the space between the individual elements and the space between the top element and the first element now keeps growing. I am forced to use thePadding.Offset
if I want consistent spacing, which is a terrible option when the goal is to create scalable UI that works on all screen sizes.
- The
ScrollingFrame.AutomaticCanvasSize
property should be the solution to perfectly fitting all of a ScrollingFrame’s children, but its implementation seems to mirror the behavior of the point above. When you set the CanvasSize of the ScrollingFrame to the AbsoluteContentSize of the UIListLayout, the CanvasSize property again updates due toPadding.Scale
being used. And so the canvas size is never the right size. This defeats the whole purpose ofScrollingFrame.AutomaticCanvasSize
.
Current work-arounds
Developers currently have a few silly work-arounds for this problem.
- Don’t use padding and instead nest the ScrollingFrame’s child elements inside slightly larger Frames which keep some ‘open space’ to mimic the behavior of the Padding property.
- Use
Padding.Offset
rather thanPadding.Scale
and run code to automatically update thePadding.Offset
to a smaller or larger number when the user’s screen size changes.
A potential solution
A potential solution to the problems described above is if developers are able to specify if Padding should use a ScrollingFrame’s AbsoluteCanvasSize or AbsoluteSize property. That way, if a developer wants to use Padding.Scale
, they can specify to use the ScrollingFrame’s AbsoluteSize instead and so when children are added to the ScrollingFrame, the padding will remain consistent as the AbsoluteSize property remains the same. This would also solve the problem of ScrollingFrame.AutomaticCanvasSize
being broken.