Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("l2")
SetUp
End Sub
Sub SetUp
Dim p As Phone
If p.SdkVersion >= 28 Then
Dim ctxt As JavaObject
ctxt.InitializeContext
ctxt.RunMethodJO("getWindow", Null).RunMethodJO("getAttributes", Null).SetField("layoutInDisplayCutoutMode", 1)
End If
GetRealSize
CallSubDelayed2(Main, "Activity_WindowFocusChanged",True)
Dim lv As LayoutValues = GetRealSize
Dim jo As JavaObject = Root
jo.RunMethod("setBottom", Array(lv.Height))
jo.RunMethod("setRight", Array(lv.Width))
Root.Height = lv.Height
Root.Width = lv.Width
Dim pm As B4XPagesManager
pm.Initialize(Root)
End Sub
Sub GetRealSize As LayoutValues
Dim lv As LayoutValues
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim WindowManager As JavaObject = ctxt.RunMethodJO("getSystemService", Array("window"))
Dim display As JavaObject = WindowManager.RunMethod("getDefaultDisplay", Null)
Dim point As JavaObject
point.InitializeNewInstance("android.graphics.Point", Null)
display.RunMethod("getRealSize", Array(point))
lv.Width = point.GetField("x")
lv.Height = point.GetField("y")
Log(lv.Height)
lv.Scale = 100dip / 100
Return lv
End Sub