Android Question Anchors not working at Runtime

JamesGreaves

Active Member
Licensed User
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?

upload_2019-1-21_16-34-43.png
 

Attachments

  • Runtime Anchors.zip
    9 KB · Views: 53

JamesGreaves

Active Member
Licensed User
B4X:
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).
 
Upvote 0
Top