-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fixed Label Overlapped by Android Status Bar When Using SafeAreaEdges="Container" in .NET MAUI #33285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PureWeen
merged 2 commits into
dotnet:inflight/current
from
NirmalKumarYuvaraj:fix-32941_Nirmal
Dec 28, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+8.51 KB
...ases.Android.Tests/snapshots/android/LayoutShouldBeCorrectOnFirstNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 32941, "Label Overlapped by Android Status Bar When Using SafeAreaEdges=Container in .NET MAUI", PlatformAffected.Android)] | ||
| public class Issue32941 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var shellContent1 = new ShellContent | ||
| { | ||
| Title = "Home", | ||
| Route = "MainPage", | ||
| Content = new Issue32941_MainPage() | ||
| }; | ||
| var shellContent2 = new ShellContent | ||
| { | ||
| Title = "SignOut", | ||
| Route = "SignOutPage", | ||
| Content = new Issue32941_SignOutPage() | ||
| }; | ||
| Items.Add(shellContent1); | ||
| Items.Add(shellContent2); | ||
| } | ||
| } | ||
|
|
||
| public class Issue32941_MainPage : ContentPage | ||
| { | ||
| public Issue32941_MainPage() | ||
| { | ||
| var goToSignOutButton = new Button | ||
| { | ||
| Text = "Go to SignOut", | ||
| AutomationId = "GoToSignOutButton" | ||
| }; | ||
| goToSignOutButton.Clicked += async (s, e) => await Shell.Current.GoToAsync("//SignOutPage", false); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = new Thickness(20), | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Main Page", | ||
| FontSize = 24, | ||
| AutomationId = "MainPageLabel" | ||
| }, | ||
| goToSignOutButton | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class Issue32941_SignOutPage : ContentPage | ||
| { | ||
| public Issue32941_SignOutPage() | ||
| { | ||
| Shell.SetNavBarIsVisible(this, false); | ||
| SafeAreaEdges = new SafeAreaEdges(SafeAreaRegions.Container); | ||
|
|
||
| var backButton = new Button | ||
| { | ||
| Text = "Back to Main", | ||
| AutomationId = "BackButton" | ||
| }; | ||
| backButton.Clicked += async (s, e) => await Shell.Current.GoToAsync("//MainPage", true); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| BackgroundColor = Colors.White, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "SignOut / Session Expiry Page", | ||
| FontSize = 24, | ||
| BackgroundColor = Colors.Yellow, | ||
| AutomationId = "SignOutLabel" | ||
| }, | ||
| backButton | ||
| } | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 33034, "SafeAreaEdges works correctly only on the first tab in Shell. Other tabs have content colliding with the display cutout in the landscape mode.", PlatformAffected.Android)] | ||
| public class Issue33034 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var tabBar = new TabBar(); | ||
| var tab = new Tab { Title = "Tabs" }; | ||
|
|
||
| tab.Items.Add(new ShellContent | ||
| { | ||
| Title = "First Tab", | ||
| AutomationId = "FirstTab", | ||
| ContentTemplate = new DataTemplate(typeof(Issue33034TabContent)), | ||
| Route = "tab1" | ||
| }); | ||
|
|
||
| tab.Items.Add(new ShellContent | ||
| { | ||
| Title = "Second Tab", | ||
| AutomationId = "SecondTab", | ||
| ContentTemplate = new DataTemplate(typeof(Issue33034TabContent)), | ||
| Route = "tab2" | ||
| }); | ||
|
|
||
| tabBar.Items.Add(tab); | ||
| Items.Add(tabBar); | ||
| } | ||
| } | ||
|
|
||
| public class Issue33034TabContent : ContentPage | ||
| { | ||
| public Issue33034TabContent() | ||
| { | ||
| // Full-width label to detect safe area padding on either side | ||
| var edgeLabel = new Label | ||
| { | ||
| Text = "EDGE LABEL", | ||
| AutomationId = "EdgeLabel", | ||
| FontSize = 18, | ||
| FontAttributes = FontAttributes.Bold, | ||
| BackgroundColor = Colors.Red, | ||
| TextColor = Colors.White, | ||
| HorizontalOptions = LayoutOptions.Fill, | ||
| HorizontalTextAlignment = TextAlignment.Center | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = { edgeLabel } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 33038, "Layout breaks on first navigation until soft keyboard appears/disappears", PlatformAffected.Android)] | ||
| public class Issue33038 : TestShell | ||
| { | ||
| protected override void Init() | ||
| { | ||
| FlyoutBehavior = FlyoutBehavior.Disabled; | ||
| Items.Add(new ShellContent { Title = "Start", Route = "start", Content = new Issue33038_StartPage() }); | ||
| Items.Add(new ShellContent { Title = "SignIn", Route = "signin", Content = new Issue33038_SignInPage() }); | ||
| } | ||
| } | ||
|
|
||
| public class Issue33038_StartPage : ContentPage | ||
| { | ||
| public Issue33038_StartPage() | ||
| { | ||
| var goToSignInButton = new Button { Text = "Go to SignIn", AutomationId = "GoToSignInButton" }; | ||
| goToSignInButton.Clicked += async (s, e) => await Shell.Current.GoToAsync("//signin", false); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Spacing = 20, | ||
| Children = { new Label { Text = "Start Page", AutomationId = "StartPageLabel" }, goToSignInButton } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class Issue33038_SignInPage : ContentPage | ||
| { | ||
| public Issue33038_SignInPage() | ||
| { | ||
| Shell.SetNavBarIsVisible(this, false); | ||
| SafeAreaEdges = new SafeAreaEdges(SafeAreaRegions.Container); | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 16, | ||
| Padding = new Thickness(20), | ||
| Children = | ||
| { | ||
| new Label { Text = "Sign In Page", BackgroundColor = Colors.Yellow, AutomationId = "SignInLabel" }, | ||
| new Entry { Placeholder = "Email", AutomationId = "EmailEntry" } | ||
| } | ||
| }; | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32941.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #if ANDROID || IOS // SafeAreaEdges not supported on Catalyst and Windows | ||
|
|
||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue32941 : _IssuesUITest | ||
| { | ||
| public Issue32941(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Label Overlapped by Android Status Bar When Using SafeAreaEdges=Container in .NET MAUI"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void ShellContentShouldRespectSafeAreaEdges_After_Navigation() | ||
| { | ||
| App.WaitForElement("MainPageLabel"); | ||
| App.Tap("GoToSignOutButton"); | ||
| App.WaitForElement("SignOutLabel"); | ||
|
|
||
| // Get the position of the label | ||
| var labelRect = App.FindElement("SignOutLabel").GetRect(); | ||
|
|
||
| // The label should be positioned below the status bar (Y coordinate should be > 0) | ||
| // On Android with notch, status bar is typically 24-88dp depending on device | ||
| // The label should have adequate top padding from SafeAreaEdges=Container | ||
| Assert.That(labelRect.Y, Is.GreaterThan(0), "Label should not be at Y=0 (would be under status bar)"); | ||
|
|
||
| // Verify the label is not overlapped by checking it has reasonable top spacing | ||
| // A label at Y < 20 is likely overlapped by the status bar | ||
| Assert.That(labelRect.Y, Is.GreaterThanOrEqualTo(20), | ||
| "Label Y position should be at least 20 pixels from top to avoid status bar overlap"); | ||
| } | ||
| } | ||
| #endif |
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33034.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #if ANDROID || IOS // SafeAreaEdges not supported on Catalyst and Windows | ||
|
|
||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue33034 : _IssuesUITest | ||
| { | ||
| public override string Issue => "SafeAreaEdges works correctly only on the first tab in Shell. Other tabs have content colliding with the display cutout in the landscape mode."; | ||
|
|
||
| public Issue33034(TestDevice device) : base(device) { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void SafeAreaShouldWorkOnAllShellTabs() | ||
| { | ||
| App.WaitForElement("EdgeLabel"); | ||
| App.SetOrientationLandscape(); | ||
| var initialRect = App.WaitForElement("EdgeLabel").GetRect(); | ||
|
|
||
| App.TapTab("Second Tab"); | ||
| App.WaitForElement("EdgeLabel"); | ||
| App.TapTab("First Tab"); | ||
| var afterSwitchRect = App.WaitForElement("EdgeLabel").GetRect(); | ||
|
|
||
| Assert.That(afterSwitchRect.X, Is.EqualTo(initialRect.X).Within(5)); | ||
| Assert.That(afterSwitchRect.Width, Is.EqualTo(initialRect.Width).Within(5)); | ||
| } | ||
| } | ||
| #endif |
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33038.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #if ANDROID || IOS // SafeAreaEdges not supported on Catalyst and Windows | ||
|
|
||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue33038 : _IssuesUITest | ||
| { | ||
| public Issue33038(TestDevice testDevice) : base(testDevice) { } | ||
|
|
||
| public override string Issue => "Layout breaks on first navigation until soft keyboard appears/disappears"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void LayoutShouldBeCorrectOnFirstNavigation() | ||
| { | ||
| App.WaitForElement("StartPageLabel"); | ||
| App.Tap("GoToSignInButton"); | ||
| App.WaitForElement("SignInLabel"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif |
Binary file added
BIN
+19.2 KB
...ts/TestCases.iOS.Tests/snapshots/ios/LayoutShouldBeCorrectOnFirstNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Issue33034TabContent page is missing the SafeAreaEdges property, but the test is specifically designed to validate SafeAreaEdges behavior across multiple tabs. Without setting SafeAreaEdges on the ContentPage, the test cannot properly validate the fix. Add the SafeAreaEdges property to ensure the test validates the intended behavior.