How is settled the x position of an element?

Hi Koders!
For a certain purpose I need to determine the position of some elements in the screen.The elements are arranged like this:
phone screen
But when I try to get the x position of an element I get strange values like this ones, using the spaces elements for reference:
spaces capture
The Screen1 width is 360:
imagen
All the horizontal arrangements are settled to right in horizontal alignment.
The x position of A, B and C labels are these ones:


But the labels have a width of 20 px and the space between them is 10 px, so I can’t understand these numbers.

I tried with Animation utilities and with @Mohamed_Tamer fantastic Component tools, but the numbers are the same.

I guess this has something to do with the Companion and the resolution of the device used to test, because the numbers are different if another device is used.

Anyway, I need to know how to get the exact X position of the labels A, B and C so I can move an sprite to the same X position, no matter wich device I’m using.

I would appreciate a little explanation about this topic.
Thanks in advance!

You need an extension like TaifunTools to get the density of screen. Normally it’s 3 for new cellphones.
So 360 * 3 = 1080, you will know the relationship

2 Likes

I tried with a factor of 3, but didn’t work either because I can’t understand the logic, I don’t know why two spaces in the same position in screen have different values for their X position.
Maybe the values are not accurate in Companion and only will be “logical” with APK?
Thanks for your answer!

If you check the arrangement it should have a with of 102dp x devicedensity 3 = 306px

bild

1 Like

Thanks Boban.
Ok, I understand that widths are measured in dp and position is given in px, but I can’t understand why two elements that in the screen have the same X position have different values for the X coordinate.
The coordinates are related to the arrangemet in wich they are and also depends on the configuration of that arrangement?
The X position of the two spaces in the blue rectangles is 1080 too.
imagen