I've placed a button at each corner of a panel and "connected" them with anchors.
When I resize the Panel at Design time, the buttons "stick" to each of their corners.
However, if I resize the Panel at Runtime, the anchors don't apply and the buttons don't "stick" to the corners.
(e.g. Panel1.Left = 0 : Panel1.Top = 0 : Panel1.Width = 100%x : Panel1.Height = 100%y)
Is there a way to make the anchors "work" at Runtime?
Anchors and designer script (in B4A) are only applied once when the layout is loaded.
I don't know exactly what you are doing however maybe you can resize the panel and only then load the layout.
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Panel1.Left = 0 : Panel1.Top = 0 : Panel1.Width = 100%x : Panel1.Height = 100%y
'Panel1.SetLayout(0,0,100%x,100%y)
Activity.LoadLayout("Main")
End Sub
I cannot set the size before loading the activity, I get an error:
java.lang.RuntimeException: Object should first be initialized (Panel).