aaronk Well-Known Member Licensed User Longtime User Oct 29, 2019 #1 Hi, In my app I am detecting if the user is using a phone or a tablet and then showing a different layout based on what device they are using. I am detecting the screen size and showing the layout like the following: Code: Copy If GetDeviceLayoutValues.ApproximateScreenSize > 6 Then phone1.SetScreenOrientation(0) Activity.LoadLayout("landscape") Log("** tablet **") Else phone1.SetScreenOrientation(1) Activity.LoadLayout("portrait") Log("** phone **") End If This has been working for some time, but now I have a customer using an OnePlus 7T phone. The issue is its rotating to landscape due to the code as above, and it should be using the phone layout. I think it's because the phone they are using is an 6.55" screen and I am telling my app if it's a 6" plus screen to rotate. Is there a better way in detecting if the user is using a large screen like a tablet or a small screen like a phone other than the code I am using above ? I guess the only way is to increase the screen size in my code like the following? Code: Copy If GetDeviceLayoutValues.ApproximateScreenSize >= 7 Then phone1.SetScreenOrientation(0) Activity.LoadLayout("landscape") Log("** tablet **") Else phone1.SetScreenOrientation(1) Activity.LoadLayout("portrait") Log("** phone **") End If
Hi, In my app I am detecting if the user is using a phone or a tablet and then showing a different layout based on what device they are using. I am detecting the screen size and showing the layout like the following: Code: Copy If GetDeviceLayoutValues.ApproximateScreenSize > 6 Then phone1.SetScreenOrientation(0) Activity.LoadLayout("landscape") Log("** tablet **") Else phone1.SetScreenOrientation(1) Activity.LoadLayout("portrait") Log("** phone **") End If This has been working for some time, but now I have a customer using an OnePlus 7T phone. The issue is its rotating to landscape due to the code as above, and it should be using the phone layout. I think it's because the phone they are using is an 6.55" screen and I am telling my app if it's a 6" plus screen to rotate. Is there a better way in detecting if the user is using a large screen like a tablet or a small screen like a phone other than the code I am using above ? I guess the only way is to increase the screen size in my code like the following? Code: Copy If GetDeviceLayoutValues.ApproximateScreenSize >= 7 Then phone1.SetScreenOrientation(0) Activity.LoadLayout("landscape") Log("** tablet **") Else phone1.SetScreenOrientation(1) Activity.LoadLayout("portrait") Log("** phone **") End If
Erel B4X founder Staff member Licensed User Longtime User Oct 29, 2019 #2 The best approach is to have a single layout with one or two variants and use anchors and designer script to make it adapt to any screen size. Upvote 0
The best approach is to have a single layout with one or two variants and use anchors and designer script to make it adapt to any screen size.