I’m unable to scale a ScrollingFrame with UIListLayout using AutomaticCanvasSize. I’ve tried using scripts to set the scrolling frame’s CanvasSize to the AbsoluteContentSize of UIListLayout, but it changes it to a random value that isn’t even what AbsoluteContentSize shows in the properties.
I am using scale to size the descendants and adding UIAspectRatioConstraint’s with aspect ratio of 1 so that they are the same size across all devices. I am unable to find any solution with offset, it just makes things worse.
The only way to make descendants size correctly with my UI is with Scale, but AutomaticCanvasSize doesn’t work with scale and as I said, I’ve tried using scripts that set the canvas size to the absolute content size of the UIListLayout but receiving lower values.
All of my frames use the size of 0.93, 0, 0.93, 0 , aspect ratio of 1 and aspect type of ScaleWithParentSize. The ScrollingFrame is only horizontal.
This is the script I tried:
script.Parent.CanvasSize = UDim2.new(0, script.Parent.UIListLayout.AbsoluteContentSize.X, 1, 0)
I’ve spent hours trying to figure out how to fix my issue, but i still haven’t found a solution. Has anyone successfully made a ScrollingFrame work with scale sized UI elements and UIListLayout? Any tips or workarounds would be really appreciated.
Could you demonstrate screenshots on how you’ve constructed your UI? I’ve done a mini test with some simple frames within a ScrollingFrame, with AspectRatio set to 1, and used a script to set the CanvasSize to the AbsoluteContentSize and it works fine for me.
Do you insert your UI items using a script? Is it possible you’re trying to set the CanvasSize from the AbsoluteContentSize before all of your items have been inserted into the UI?
No, I don’t insert them through a script. It’s a daily rewards system so they are all inside the scrolling frame by default. The frame inside Day1 is where the text and all that stuff is located, i have it like that so i can move the anchor point and animate them
What does your UI look like? How does the problem manifest? And having the frame inside the listed UI object in your list is gud practice I like doing that myself so you can animate the scale of the button without messing up the automatic positioning.
This is how the UI looks for now, as i’m still revamping it. Right now the problem is that usually AbsoluteContentSize returns something lower than what it says on the properties, per example, if AbsoluteContentSize was ~1100, then it returns ~400 when i print it, and that makes it unable to reach the last day or just not being able to scroll at all
What’s the padding set to in your UIListLayout? I just found out that setting the padding using scale isn’t a great solution if you’re dynamically adjusting the CanvasSize, since the padding is relative to the CanvasSize, re-sizing the canvas to be bigger by result increases the padding between the items and the CanvasSize is therefore wrong again.
Ah yes, this is likely causing the issue. Do you have a lot of listed items? If so, the total scale of the padding will build up quickly. Right now you have the scale set to 0.01, or 1% of the current size of the CanvasSize. Since you set the CanvasSize to the current absolute width of the list, the UIListLayout then updates immediately after, re-positioning the elements even further apart since the canvas is now larger and the padding will thus be larger too.
My recommendation is to switch the padding in UIListLayout to (0, 10) or adjust pixel offset to your liking - this means the padding is sized by absolute distance in pixels rather than relatively to the parent size, cuz if the parent size changes then so does the padding and it will never be satisfied.
Hmm right, well next solution. Try putting your resizing code in a “while true do” loop with a short wait? This will constantly resize the canvas, so if the problem is only setting it once at the beginning, then this will overcome that.