Skip to content

[BUG] StatusBar overlay missing tag on Android causes multiple overlays to be created #3132

@IgrisModz

Description

@IgrisModz

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

On Android 35+, multiple StatusBar overlays are stacked on top of each other in the DecorView. A new overlay is created every time StatusBar.SetColor() is called because FindViewWithTag("StatusBarOverlay") always returns null.
This causes:
• Visual artifacts when trying to hide the status bar
• Memory waste from orphaned views
• Fullscreen implementations failing to completely hide the status bar area

Expected Behavior

Only one StatusBar overlay should exist, and its background color should be updated when StatusBar.SetColor() is called (same behavior as NavigationBar).

Steps To Reproduce

  1. Create a .NET MAUI app targeting Android 35+
  2. Set different StatusBar.SetColor() values on different pages (e.g., MainPage has one color, SettingsPage has another)
  3. Navigate between these pages multiple times
  4. Enter fullscreen mode or inspect the DecorView hierarchy
  5. Observe multiple StatusBar overlays stacked

Link to public reproduction project repository

https://github.com/IgrisModz/Scan-Manga

Environment

•	.NET version: 10
•	CommunityToolkit.Maui version: 14.0.1
•	Target Android API: 35
•	Device: Any Android 35+ device/emulator

Anything else?

Root Cause:
In StatusBar.android.cs (lines ~50-60), the overlay is created but the Tag is never set:

statusBarOverlay = new(Activity)
{
    LayoutParameters = new FrameLayout.LayoutParams(...)
    {
        Gravity = GravityFlags.Top
    }
};
// ❌ Missing: statusBarOverlay.Tag = statusBarOverlayTag;
decorGroup.AddView(statusBarOverlay);

Meanwhile, NavigationBar.android.cs correctly sets the tag:

navigationBarOverlay.Tag = navigationBarOverlayTag; // ✅

Suggested Fix:
Add the missing line after creating the StatusBar overlay:

statusBarOverlay.Tag = statusBarOverlayTag;

Workaround:
Until this is fixed, a workaround is to find all StatusBar overlays by their layout characteristics (Gravity.Top, MatchParent width, and height = status_bar_height + 3) instead of using FindViewWithTag.
👉 FullscreenService.cs workaround implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions