I'm fairly new to this, so sorry if this is a dumb question. How do I get my Xamarin.Forms app to start below the status bar or the notch when applicable? I've tried using a NavigationPage
, but then it started wear below the top of the screen. I've also seen a few other solutions, but I can't make it work.
Can anyone help?
Thanks!
(from this answer)
Stretching elements out of the bounds of the safe area is arguably a use case in the case you provided. The bar is a mere background element and not content, as the navigation bar is, which also stretches to fill the whole screen.
Having said that, you unfortunately don't get this for free, but have to implement this by yourself. Assume you have the following XAML
In your code-behind (I would not use it like this, but to make the point it suffices. For a real application I have written a utility class, which is attached to the view and manages the insets.) you can now check for the property
SafeAreaInsets
being changedHow you set the
Padding
s of your views depends on your layouts, but this way you have a bit more control on how the safe area insets are used, although it is a bit fiddly.use UseSafeArea
You'll need to consider the safe area but have the background colors expand to take the full screen. So you shouldn't use
this will box your page with large empty spaces on the bottom and top edges.
Instead, you should measure the safe areas and apply it as padding to your root view.
then in xaml:
ref: https://xamarinhelp.com/safeareainsets-xamarin-forms-ios/ Thank Adam, not me!