iOS Question Programmatically Moving views in b4i


Licensed User
Longtime User
Hi, in b4a I typically move views around (to center them, etc.) programatically however the way I think it should work in B4I isn't working:

Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page

Private Button1 As Button
End Sub

Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
Button1.Left = GetDeviceLayoutValues.Width/2-Button1.Width/2 = GetDeviceLayoutValues.Height/2-Button1.Height/2

End Sub

the test layout contains a single button, button1. When I run it on the iphone the button does not move. What am I missing? And thanks!


B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

You should go over these tutorials:
Layouts, Pages and ViewControllers
Visual Designer

1. The page size is only correct inside Page_Resize event.
2. You need to set the layout file Handle Resize Event property to False if you want to override the view location.
Upvote 0