Andrew (Digitwell) Well-Known Member Licensed User Longtime User Jun 1, 2022 #1 I am using the code for safe area insets: https://www.b4x.com/android/forum/t...or-managing-multiple-pages.118901/post-746585 on b4xpages. However, it produces different results on different iPhones. iPhone 11 iPhone 8 with safe area insets code iphone 8 without safe area insets code. Any idea what is going on? B4X: Copy private Sub b4xpage_resize(w As Float, h As Float) #if B4i Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets Root.SetLayoutAnimated(0, r.Left, r.Top, w - r.Right - r.Left, h - r.Bottom - r.Top) #end if End Sub
I am using the code for safe area insets: https://www.b4x.com/android/forum/t...or-managing-multiple-pages.118901/post-746585 on b4xpages. However, it produces different results on different iPhones. iPhone 11 iPhone 8 with safe area insets code iphone 8 without safe area insets code. Any idea what is going on? B4X: Copy private Sub b4xpage_resize(w As Float, h As Float) #if B4i Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets Root.SetLayoutAnimated(0, r.Left, r.Top, w - r.Right - r.Left, h - r.Bottom - r.Top) #end if End Sub
Alexander Stolte Expert Licensed User Longtime User Jun 1, 2022 #2 I don't use a safe region at all for the top value, only for the bottom. Are there any problems when you set it to 0? I also never resize the root panel, is there a reason for this? Upvote 0
I don't use a safe region at all for the top value, only for the bottom. Are there any problems when you set it to 0? I also never resize the root panel, is there a reason for this?
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Jun 1, 2022 #3 Alexander Stolte said: I don't use a safe region at all for the top value, only for the bottom. Are there any problems when you set it to 0? I also never resize the root panel, is there a reason for this? Click to expand... I was just using the code provided by Erel in the b4xpages tutorial thread. I will try your suggestion. Upvote 0
Alexander Stolte said: I don't use a safe region at all for the top value, only for the bottom. Are there any problems when you set it to 0? I also never resize the root panel, is there a reason for this? Click to expand... I was just using the code provided by Erel in the b4xpages tutorial thread. I will try your suggestion.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Jun 1, 2022 #4 tried this. B4X: Copy private Sub b4xpage_resize(w As Float, h As Float) #if B4i Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets Root.SetLayoutAnimated(0, r.Left, 0, w - r.Right - r.Left, h - r.Bottom) #end if End Sub unfortunately it looks the same as the iphone 8 with insets Upvote 0
tried this. B4X: Copy private Sub b4xpage_resize(w As Float, h As Float) #if B4i Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets Root.SetLayoutAnimated(0, r.Left, 0, w - r.Right - r.Left, h - r.Bottom) #end if End Sub unfortunately it looks the same as the iphone 8 with insets
Erel B4X founder Staff member Licensed User Longtime User Jun 2, 2022 #5 You are not using the standard navigation bar, right? Using it will make the behavior simpler and will also look more standard. Can you reproduce it in a small project? Upvote 0
You are not using the standard navigation bar, right? Using it will make the behavior simpler and will also look more standard. Can you reproduce it in a small project?
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Jun 2, 2022 #6 I turn off the standard Nav bar. B4X: Copy #if b4i Main.NavControl.NavigationBarVisible = False #end if Here is a sample project that demonstrates the issue. I have tried it on Apple phones with buttons , iPhone 8 this show the problem, and without button, iPhone 11, which is fine. Attachments safearea.zip safearea.zip 70.2 KB · Views: 492 Upvote 0
I turn off the standard Nav bar. B4X: Copy #if b4i Main.NavControl.NavigationBarVisible = False #end if Here is a sample project that demonstrates the issue. I have tried it on Apple phones with buttons , iPhone 8 this show the problem, and without button, iPhone 11, which is fine.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Jun 2, 2022 #7 I don't use the standard nav as the client design can have several icons at the top of the screen. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jun 3, 2022 #8 I'm not sure why the iPhone 8 behaves differently. This code seems to solve it: Code: Copy Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets r.Top = Max(20, r.Top) Root.SetLayoutAnimated(0, r.Left, r.Top, w - r.Right - r.Left, h - r.Bottom - r.Top) Upvote 0
I'm not sure why the iPhone 8 behaves differently. This code seems to solve it: Code: Copy Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets r.Top = Max(20, r.Top) Root.SetLayoutAnimated(0, r.Left, r.Top, w - r.Right - r.Left, h - r.Bottom - r.Top)