uno
uno copied to clipboard
[Android][iOS] ApplicationView.GetForCurrentView().VisibleBounds returns a Rectangle with all values set to 0
Current behavior
For instance, when having this logic to set the bottom bar
#if __ANDROID__ || __IOS__
var full = App.Instance.MainWindow!.Bounds;
var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
var bottomPadding = full.Bottom - bounds.Bottom;
#else
var bottomPadding = 0;
#endif
TestTextBlock.Text = bottomPadding.ToString();
if (bottomPadding > 0)
{
SafeAreaRow.Height = new GridLength(bottomPadding);
}
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<!-- SafeAreaRow.Height is set in code behind -->
<RowDefinition x:Name="SafeAreaRow"
Height="0" />
</Grid.RowDefinitions>
<TextBlock x:Name="TestTextBlock"
FontSize="20"
VerticalAlignment="Center" />
<Border Background="Red"
Grid.Row="1" />
</Grid>
it looks like this
Expected behavior
ApplicationView.GetForCurrentView().VisibleBounds
should return a Rect
with the dimension of the screen excluding phone edges.
How to reproduce it (as minimally and precisely as possible)
- Download this sample BottomBoundsIssue-latest.zip
- Deploy on Android/iOS
Workaround
N/A
Works on UWP/WinUI
None
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
5.2.0-dev.683
Affected platforms
Android, iOS
IDE
Visual Studio 2022
IDE version
17.10.0 Preview 1.0
Relevant plugins
No response
Anything else we need to know?
I've found this bug while trying to create a sample for this issue #15520
This feels similar to https://github.com/unoplatform/nventive-private/issues/510, what do you think @kazo0?