From b5b75c751f0bd69503823081cb57e5ac8e625a8e Mon Sep 17 00:00:00 2001 From: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:53:06 +0530 Subject: [PATCH] Committed the changes --- .../Android/MauiWindowInsetListener.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Core/src/Platform/Android/MauiWindowInsetListener.cs b/src/Core/src/Platform/Android/MauiWindowInsetListener.cs index dd26fea690a1..e9a655edb7e2 100644 --- a/src/Core/src/Platform/Android/MauiWindowInsetListener.cs +++ b/src/Core/src/Platform/Android/MauiWindowInsetListener.cs @@ -284,10 +284,26 @@ public MauiWindowInsetListener() : base(DispatchModeStop) contentView?.SetPadding(0, 0, 0, 0); } - // Pass insets through unconsumed so child views receive them intact. - // Bottom: BottomNavigationView needs the nav bar inset to extend its background in Edge-to-Edge mode (Issue #33344). - // Top: SafeAreaExtensions handles per-view overlap, avoiding double-padding. - return insets; + // Consume top inset when AppBar is visible — it already pads itself, so downstream + // views must not receive a top inset or SafeAreaExtensions will double-apply it. + // Bottom inset is passed through unconsumed so BottomNavigationView can extend its + // background into the system navigation bar area (issue #33344). + var newSystemBars = Insets.Of( + systemBars?.Left ?? 0, + appBarHasContent ? 0 : systemBars?.Top ?? 0, + systemBars?.Right ?? 0, + systemBars?.Bottom ?? 0) ?? Insets.None; + + var newDisplayCutout = Insets.Of( + displayCutout?.Left ?? 0, + appBarHasContent ? 0 : displayCutout?.Top ?? 0, + displayCutout?.Right ?? 0, + displayCutout?.Bottom ?? 0) ?? Insets.None; + + return new WindowInsetsCompat.Builder(insets) + ?.SetInsets(WindowInsetsCompat.Type.SystemBars(), newSystemBars) + ?.SetInsets(WindowInsetsCompat.Type.DisplayCutout(), newDisplayCutout) + ?.Build() ?? insets; } public void TrackView(AView view)