Android Question Layout locked to portrait

Liew

Member
Licensed User
Longtime User
Normal.jpg
Only_Potrait.jpg
Main module in B4Xpages:
#Region  Project Attributes
[/QUOTE]
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: Landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
'Phone spec is 800 x 1340 pixels
    #FullScreen: True
    #IncludeTitle: False
    #SupportedOrientations: Landscape
#End Region

B4xpage create:
Dim lv As LayoutValues = GetDeviceLayoutValues
        Ys = lv.Height : Xs = lv.Width
        'Width1 & height1 800  1276 - due to autorotate
        Log("Xs1 = '"&Xs&"  "&"Ys1 = "&Ys)
        Log("Screen1 100%x = "&100%x&" 100%y = "&100%y)
        If (Ys > Xs ) Then
            Log("Portrait1 detected")
            'ptrait_det = True
            Xs = 1340 : Ys = 736
        End If


Sample resize codes :
B4XPages.MainPage.RootMP.RemoveAllViews
    Log("device layout_login "&GetDeviceLayoutValues)
    Dim lv As LayoutValues = GetDeviceLayoutValues
    Ys = lv.Height : Xs = lv.Width
    scalex = Xs/Ys
    Log("New X Y in HChange "&Xs& "   "&Ys)
    Log("Redraw screen")
    
    B4XPages.MainPage.RootMp.LoadLayout("Login_Pg")
  'Below module will utilise the detected size to redraw the screen
    Login_Page_Ctr

I noticed that my layout will stick to the portrait width if I rotate the tablet from Landscape to Portrait during app deployment.
In B4xpages, I tried to remove the view and draw with the newly detected landscape x,y sizes, but it seems that the tablet is controlling the screen display.
Is there anything I can do with it using my code?
Note: This issue will not exist if I kept the tablet stayed at a fixed orientation(either portrait or landscape) during deployment
Thanks
Rgds,
Liew
 

PaulMeuris

Active Member
Licensed User
You probably know by now that it is not recommended to use more than one orientation.
The setting for the device could be:
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
The "unspecified" setting allows you to use both orientations.
Look at the B4XPages events to determine where you should put your code to adjust the layout.
 
Upvote 0
Top