How to change the screen orientation?

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I want to let you change the screen orientation only when it is a tablet, how I can do this?

B4X:
#Region Project Attributes
  #SupportedOrientations: portrait   
#End Region

Sub Process_Globals
  Dim bIsTablet As Boolean = False
End Sub

Sub Activity_Create(FirstTime As Boolean)
  If GetDevicePhysicalSize > 6 Then    ' 7" o 10" tablet
    bIsTablet = True     
    '
    #SupportedOrientations = unspecified    ' <-- how I can do this?   
    '    
  End If   
End Sub
  
Sub GetDevicePhysicalSize As Float
  Dim lv As LayoutValues
  lv = GetDeviceLayoutValues
  Return Sqrt(Power(lv.Height / lv.Scale / 160, 2) + Power(lv.Width / lv.Scale / 160, 2))
End Sub
Thanks and regards.
:)
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, again.
I have encountered a problem, see if you can help me.
My project consists of many 'Activity'. With the above code only lets you change the screen orientation in the main activity, but the others are always in 'portrait'.
Does this have to control in each 'activity'?

Thanks and regards.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, then it seems that it is necessary in each 'activity'.
Thank you very much and regards.
:)
 
Upvote 0
Top