Android Question Is possible to set SupportedOrientations to differents values in the same code (phone or tablet)?

asales

Expert
Licensed User
Longtime User
I want to use the "portrait" orientation to phones and "unspecified" orientation to tablets.

I try this code in main activity, but don't works:
B4X:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    If GetDeviceLayoutValues.ApproximateScreenSize > 6 Then
        #SupportedOrientations: unspecified
    Else
        #SupportedOrientations: portrait
    End If
Is possible to set orientation to phone (= portrait) and tablet (=unspecified)?
How I can do this?

Thanks in advance for any tip.
 

derez

Expert
Licensed User
Longtime User
Something like this (phone is portrait and tablet landscape):
B4X:
Dim lv As LayoutValues
lv = GetDeviceLayoutValues
If lv.ApproximateScreenSize > 6.5 Then
    ph.SetScreenOrientation(0)
Else
    ph.SetScreenOrientation(1)
End If
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Something like this (phone is portrait and tablet landscape):
B4X:
Dim lv As LayoutValues
lv = GetDeviceLayoutValues
If lv.ApproximateScreenSize > 6.5 Then
    ph.SetScreenOrientation(0)
Else
    ph.SetScreenOrientation(1)
End If
Thanks!
I found this option too: ph.SetScreenOrientation(-1) = unspecified
but I need to put this code in every activity?
There is a way to set a orientation to tablet = unspecified and phone = portrait to whole project?
 
Upvote 0
Top