Place the controls on the screen using the code

If I put the following code in the “Pressed” event of a button, it works:

var l As Integer=self.Size.Width
var h As Integer=self.Size.Height

But if I put it in the “Opening” event of the same button, it doesn’t work. And if I move it to the “Activated” or “Opening” event of a screen, ditto.

How do I reposition the controls when a screen is opened?

Are you just trying to set the control to be the same relative size based on the window?

If so you do not need code at all. Simply position the control on the IDE window as you want it and then click on the lock indicators to keep that relative position in place.

Clicking the padlock on a given side keeps that side of the control the specified distance from that edge of its container (such as a window). This works even when the window is resized.

as I said in my other post, it doesn’t work if the control is positioned under the layout with the lock on the bottom of the screen. And if I put all the controls inside the layout, it’s very difficult to see, because everything overlaps so much, as the layout in the IDE is so small (for example, for an app in landscape mode on large phones or tablets).
Here, the question is to position the controls via the code please. This should be possible, as the members of the Xojo team have mentioned it several times.

Sorry, but you can’t expect people to know to look at another thread for vital details. You should keep the details in this post that are relevant. Not everyone reads every post.

For mobile you typically need to setup constraints between controls that allow the layout to operate no matter what the screen size is. I’ve not played with Android in Xojo so I’ll leave it to someone else to comment.

The video is for iOS but may be relevant: