iOS Question Resize layout on startup

angel_

Well-Known Member
Licensed User
Longtime User
I currently have many views (about 40) in each Layout that I resize by code (now it takes several seconds). Where should I put the call to load each Page so that it does not slow down the loading of the design?

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1

    LoadLayout
End Sub

Sub LoadLayout
    Wait For B4XPage_Resize(Width As Int, Height As Int)
    
    ResizeViews_Page1
    ResizeViews_Page2
    ResizeViews_Page3
    ResizeViews_Page4

    '....code
End Sub

Private Sub B4XPage_Resize (Width As Float, Height As Float)
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
End Sub
 
Solution
The first Wait For B4XPage_Resize will "steal" the event. It is better to do remove it :
B4X:
Private Sub B4XPage_Resize (Width As Float, Height As Float)
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
    'Resize views
        
End Sub

Erel

B4X founder
Staff member
Licensed User
Longtime User
The first Wait For B4XPage_Resize will "steal" the event. It is better to do remove it :
B4X:
Private Sub B4XPage_Resize (Width As Float, Height As Float)
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
    'Resize views
        
End Sub
 
Upvote 0
Solution
Top