Android Question Maintain Panel Aspect Ratio, on Foldables

james_sgp

Active Member
Licensed User
Longtime User
Hi all,
I need advise on how i can fix a panels aspect ratio from the front screen onto the inner screen of a foldable device. I have tried alot of variations of this code, with Resise/Appear, etc. but i getting similar issue, that panel fills the puter screen but when opening the inner screen is narrow (as expected, but the bottom is cut off). Then when close the fold and going back to the outer screen then its bottom is cut off? Desperately seeking a proper solution to handle foldables ( i simple want to retain a standard portrait aspect ration on inner and outer screens).

Resizing panel:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Panel1 As Panel
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    AdjustPanel
End Sub

Private Sub B4XPage_Resize (Width As Int, Height As Int)
    AdjustPanel
End Sub

Private Sub AdjustPanel
    Panel1.Left = 0
    Panel1.Top = 0
    Panel1.Width = Root.Width
    Panel1.Height = Root.Height
    
    Log($"Root: ${Root.Width}x${Root.Height} @ (${Root.Left},${Root.Top})"$)
    Log($"Panel1: ${Panel1.Width}x${Panel1.Height} @ (${Panel1.Left},${Panel1.Top})"$)
End Sub
 
Top