I think the following issue is related to the one reported here https://www.b4x.com/android/forum/threads/is-incrorrect-activity-height-still-an-issue.114435/. However, I am seeing the problem when an app is started with the device's screen off. I discovered the issue because my app runs in the background and can restart itself (hence the screen is usually off when the app starts). To replicate the scenario, run the attached project, connect your device to the B4A IDE, turn off the device's screen and start the app via the IDE.
The MainPage layout is created in the Designer and consists of a single panel, with a red border, that is resized by the Designer to fill the activity. Starting the app with the screen on, the border is displayed as expected. Starting the app with the screen off, the bottom border is lost. As per the above linked thread, the Activity height doesn't seem to be set correctly with the screen off. The problem can be partially addressed by using the approach Erel suggested in the above thread (using ime_HeightChanged and manually setting the layout) however, relying on the Designer to size the layout will not work when the app is started with the screen off.
Started with the screen on:
Started with the screen off:
Adding Erel's IME suggestion:
Which produces, when starting with the screen on:
root height=1851
updated height=1851
When started with the screen off:
root height=1995
updated height=1995
and then turning the screen on:
root height=1995
updated height=1851
Root height never takes on the correct value of 1851.
The MainPage layout is created in the Designer and consists of a single panel, with a red border, that is resized by the Designer to fill the activity. Starting the app with the screen on, the border is displayed as expected. Starting the app with the screen off, the bottom border is lost. As per the above linked thread, the Activity height doesn't seem to be set correctly with the screen off. The problem can be partially addressed by using the approach Erel suggested in the above thread (using ime_HeightChanged and manually setting the layout) however, relying on the Designer to size the layout will not work when the app is started with the screen off.
B4X:
Sub Class_Globals
Private Root As B4XView
End Sub
Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Sub B4XPage_Appear
Log("root height=" & Root.Height)
End Sub
Started with the screen on:
Started with the screen off:
Adding Erel's IME suggestion:
B4X:
Sub Class_Globals
Private Root As B4XView
Private updatedHeight As Int
End Sub
Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Dim ime As IME
ime.Initialize("ime")
ime.AddHeightChangedEvent
updatedHeight = 100%y
Root.LoadLayout("MainPage")
End Sub
Sub B4XPage_Appear
Log("root height=" & Root.Height)
Log("updated height=" & updatedHeight)
End Sub
Sub ime_HeightChanged (NewHeight As Int, OldHeight As Int)
updatedHeight = NewHeight
End Sub
Which produces, when starting with the screen on:
root height=1851
updated height=1851
When started with the screen off:
root height=1995
updated height=1995
and then turning the screen on:
root height=1995
updated height=1851
Root height never takes on the correct value of 1851.