-
Notifications
You must be signed in to change notification settings - Fork 493
Fix: [BUG] StatusBar too large in landscape mode (in API 36+) #3170 #3182
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,23 +51,44 @@ static void PlatformSetColor(Color color) | |
|
|
||
| if (statusBarOverlay is null) | ||
| { | ||
| var statusBarHeight = Activity.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0; | ||
| var statusBarPixelSize = statusBarHeight > 0 ? Activity.Resources?.GetDimensionPixelSize(statusBarHeight) ?? 0 : 0; | ||
|
|
||
| statusBarOverlay = new(Activity) | ||
| void SetupStatusBarOverlay(int statusBarPixelSize) | ||
| { | ||
| LayoutParameters = new FrameLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, statusBarPixelSize + 3) | ||
| statusBarOverlay = new(Activity) | ||
| { | ||
| Gravity = GravityFlags.Top | ||
| } | ||
| }; | ||
|
|
||
| statusBarOverlay.Tag = statusBarOverlayTag; | ||
| decorGroup.AddView(statusBarOverlay); | ||
| statusBarOverlay.SetZ(0); | ||
| LayoutParameters = | ||
| new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, | ||
| statusBarPixelSize + 3) | ||
| { | ||
| Gravity = GravityFlags.Top | ||
| } | ||
| }; | ||
|
|
||
| statusBarOverlay.Tag = statusBarOverlayTag; | ||
| decorGroup.AddView(statusBarOverlay); | ||
| statusBarOverlay.SetZ(0); | ||
| statusBarOverlay.SetBackgroundColor(platformColor); | ||
| } | ||
|
|
||
| if (OperatingSystem.IsAndroidVersionAtLeast(36)) | ||
| { | ||
| window.DecorView.Post(() => | ||
| { | ||
| var insets = window.DecorView.RootWindowInsets; | ||
| var top = insets?.GetInsets(WindowInsets.Type.StatusBars()).Top ?? 0; | ||
|
|
||
|
Comment on lines
+74
to
+78
|
||
| SetupStatusBarOverlay(top); | ||
| }); | ||
| } | ||
| else | ||
| { | ||
| var statusBarHeight = Activity.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0; | ||
| var statusBarPixelSize = statusBarHeight > 0 | ||
| ? Activity.Resources?.GetDimensionPixelSize(statusBarHeight) ?? 0 | ||
| : 0; | ||
|
|
||
| SetupStatusBarOverlay(statusBarPixelSize); | ||
| } | ||
| } | ||
|
|
||
| statusBarOverlay.SetBackgroundColor(platformColor); | ||
| } | ||
| else | ||
| { | ||
|
|
||
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.
SetBackgroundColor(platformColor)is now only called when the overlay is first created. IfstatusBarOverlayalready exists (found by tag), this method no longer updates its color, so subsequentPlatformSetColorcalls won't change the overlay color. Consider moving the background-color update back outside theif (statusBarOverlay is null)block (and/or updating it in the existing-overlay path).