iOS Question Programmatically Moving views in b4i

DoctorDebug

Member
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.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("test")
Button1.Left = GetDeviceLayoutValues.Width/2-Button1.Width/2
Button1.top = GetDeviceLayoutValues.Height/2-Button1.Height/2

NavControl.ShowPage(Page1)
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!
 

Erel

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
Top