UIListLayout not accurate

I recently created a type of grid, using a UIListLayout to space out the lines evenly on the X plane. The problem is, the UIListLayout does not seem to be spacing my lines accurately.

I have a bunch of grey lines, and a bunch of pink lines.
The pink lines should only occur 1 time for every 4 grey lines.

For some reason, when I set padding on the pink lines to 4 times the grey line padding, it does not stay even to the grey lines.

Example:

When pink and grey offset is 20:
image

When I shift the pink line offset to 4 times the grey (80).
image

As you can see, even though I increased the padding by exactly 4 times, the lines do not line up.
Why is this, and how do I fix it?

1 Like

I don’t really use UIListLayout that much, but have you tried using the scale instead of offset to see if that changes anything.

I kind of need to use offset, because all my math calculations that work with the grid, work on a pixel basis. Thanks for the suggestion though!

This could just be an error on robloxs end, because in theory increasing it 4x should line up.

1 Like

That is exactly why I made this post. This seemed like a very strange thing to happen.

Padding is the distance between the edges of the lines, not from their center point. This means that the thickness of the lines will make the grey and pink lines slowly desync. Here’s a very scientific picture:
image.

You can change the padding value of the UIListLayout through a script so the offsets are correct. For example, for the pink lines the padding should be set to something like

UIListLayout.Padding = UDim.new(0, 80 - LinePixelThickness.X/2)
1 Like

I think you’ve got the right idea. However, I tried incorporating your concept, and they still don’t seem to line up:

Have you done the same for the gray lines? They will also be affected by the same problem.

1 Like

Of course, i am so dumb. Thanks so much for your help! I don’t know how I didn’t realize this beforehand.

1 Like