Skip to content

Commit b6a7f12

Browse files
committed
chore: Handle DeocrView FitsSystemWindows
1 parent d43a063 commit b6a7f12

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Uno.UI/UI/Xaml/Window/Native/NativeWindowWrapper.Android.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ internal void RaiseNativeSizeChanged()
103103
Rect windowBounds;
104104
Rect visibleBounds;
105105

106+
var decorView = activity.Window.DecorView;
107+
var fitsSystemWindows = decorView.FitsSystemWindows;
108+
106109
if ((int)Android.OS.Build.VERSION.SdkInt < 35)
107110
{
108111
var opaqueInsetsTypes = insetsTypes;
@@ -134,9 +137,19 @@ internal void RaiseNativeSizeChanged()
134137
this.Log().LogDebug($"Insets: {insets}");
135138
}
136139

137-
// Edge-to-edge is default on Android 15 and above
138-
windowBounds = new Rect(default, GetWindowSize());
139-
visibleBounds = windowBounds.DeflateBy(insets);
140+
if (fitsSystemWindows)
141+
{
142+
// The window bounds are the same as the display size, as the system insets are already taken into account by the layout
143+
windowBounds = new Rect(default, GetWindowSize().Subtract(insets));
144+
visibleBounds = windowBounds;
145+
}
146+
else
147+
{
148+
// Edge-to-edge is default on Android 15 and above
149+
windowBounds = new Rect(default, GetWindowSize());
150+
visibleBounds = windowBounds.DeflateBy(insets);
151+
}
152+
140153
}
141154

142155
if (this.Log().IsEnabled(LogLevel.Debug))

0 commit comments

Comments
 (0)