S stanks Active Member Licensed User Longtime User Jul 22, 2014 #1 Hi I have activity 1 with project attributes where i can lock orientation. How to lock orientation on activity 2, 3, etc. which are called from main (1) activity? thanks
Hi I have activity 1 with project attributes where i can lock orientation. How to lock orientation on activity 2, 3, etc. which are called from main (1) activity? thanks
AllyAndroid Member Licensed User Longtime User Jul 22, 2014 #2 You can set the orientation of an activity by adding the following: B4X: Sub Globals ' Phone Variable Private ph As Phone End Sub B4X: Sub Activity_Resume ' 1 = Portrait ' 2 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub You will need to add this line of code where you want to release the screen orientation: B4X: PH.SetScreenOrientation(-1) Or you can use this function created by Stevel05: http://www.b4x.com/android/forum/threads/freeze-orientation.41681/ Upvote 0
You can set the orientation of an activity by adding the following: B4X: Sub Globals ' Phone Variable Private ph As Phone End Sub B4X: Sub Activity_Resume ' 1 = Portrait ' 2 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub You will need to add this line of code where you want to release the screen orientation: B4X: PH.SetScreenOrientation(-1) Or you can use this function created by Stevel05: http://www.b4x.com/android/forum/threads/freeze-orientation.41681/
Lello1964 Well-Known Member Licensed User Longtime User Jun 23, 2021 #4 AllyAndroid said: You can set the orientation of an activity by adding the following: B4X: Sub Globals ' Phone Variable Private ph As Phone End Sub B4X: Sub Activity_Resume ' 1 = Portrait ' 2 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub You will need to add this line of code where you want to release the screen orientation: B4X: PH.SetScreenOrientation(-1) Or you can use this function created by Stevel05: http://www.b4x.com/android/forum/threads/freeze-orientation.41681/ Click to expand... There is an error, 0 = Landscape this is right : B4X: Sub Activity_Resume ' 1 = Portrait ' 0 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub Upvote 0
AllyAndroid said: You can set the orientation of an activity by adding the following: B4X: Sub Globals ' Phone Variable Private ph As Phone End Sub B4X: Sub Activity_Resume ' 1 = Portrait ' 2 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub You will need to add this line of code where you want to release the screen orientation: B4X: PH.SetScreenOrientation(-1) Or you can use this function created by Stevel05: http://www.b4x.com/android/forum/threads/freeze-orientation.41681/ Click to expand... There is an error, 0 = Landscape this is right : B4X: Sub Activity_Resume ' 1 = Portrait ' 0 = Landscape ' 9 = Reverse Portrait ' 8 = Reverse Landscape ph.SetScreenOrientation(1) End Sub