I am trying to use panels to layout the controls such that my app will look good in landscape and portrait mode.
So I located the views on two layouts, and I created two panels, one loaded with each layout, the idea being to place the panels vertically one above the other in portrait and horizontally side by side in landscape.
The layout of the panels on the screen runs fine (I set different backgrounds on the panel to check).
However, the only views that show up on the panels are those that are LEFT aligned in the Designer. Those that are BOTH or RIGHT aligned do not show at all, I suspect they fall outside the physical dimensions of the panel.
Any suggestion how to fix this, or a better method altogether?
I want to avoid having to locate each view individually, which is what I was doing before and is very hard to maintain across different screen sizes.
Here is the code I use in the activity:
So I located the views on two layouts, and I created two panels, one loaded with each layout, the idea being to place the panels vertically one above the other in portrait and horizontally side by side in landscape.
The layout of the panels on the screen runs fine (I set different backgrounds on the panel to check).
However, the only views that show up on the panels are those that are LEFT aligned in the Designer. Those that are BOTH or RIGHT aligned do not show at all, I suspect they fall outside the physical dimensions of the panel.
Any suggestion how to fix this, or a better method altogether?
I want to avoid having to locate each view individually, which is what I was doing before and is very hard to maintain across different screen sizes.
Here is the code I use in the activity:
B4X:
Sub Globals
Private pnlPage1, pnlPage2 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim pnlWidth, pnlHeight, pnl2Top, pnl2Left As Int
If 100%y > 100%x Then
' Portrait
pnlWidth = 100%x
pnlHeight = 50%y
pnl2Top = pnlHeight
pnl2Left = 0
Else
' landscape
pnlWidth = 50%x
pnlHeight = 100%y
pnl2Top = 0
pnl2Left = pnlWidth
End If
pnlPage1.Initialize( "" )
pnlPage1.LoadLayout( "Panel1" )
Activity.AddView( pnlPage1, 0, 0, pnlWidth, pnlHeight )
pnlPage1.Visible = True
pnlPage2.Initialize( "" )
pnlPage2.LoadLayout( "Panel2" )
Activity.AddView( pnlPage2, pnl2Left, pnl2Top, pnlWidth, pnlHeight )
pnlPage2.Visible = True
End Sub