dotnet / dotnet/maui

Custom Shell TabBar handler applies margin to navigation bar and page shows black background under TabBar (Android, .NET MAUI 10)

Open
#33,360 11 comments 0 reactions 0 assignees View on GitHub
area-safearea i/regression platform/android regressed-in-10-rc2 s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

I’m customizing the Shell TabBar on Android using a custom ShellRenderer and ShellBottomNavViewAppearanceTracker to create a floating TabBar with rounded corners and margins.

There are two main issues:

TabBar Margin Affects Navigation Layout
When applying margins and rounded corners to the BottomNavigationView, the margin affects both the TabBar and the navigation/root layout. This creates unexpected spacing above the TabBar and prevents it from appearing as a clean floating element.

Page Background Does Not Extend Under TabBar
Even when SafeAreaEdges="None" is set on the page, the area behind the floating TabBar is rendered black instead of using the page background color.

Environment:

.NET MAUI 10

Platform: Android

Shell-based navigation

Custom ShellRenderer and ShellBottomNavViewAppearanceTracker

Code Sample:
namespace Myapp.Platforms.Android
{
class CustomShellHandler : ShellRenderer
{
protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
{
return new CustomShellBottomNavViewAppearanceTracker(this, shellItem.CurrentItem);
}
}

class CustomShellBottomNavViewAppearanceTracker : ShellBottomNavViewAppearanceTracker
{
private readonly IShellContext shellContext;

public CustomShellBottomNavViewAppearanceTracker(
IShellContext shellContext,
ShellItem shellItem
) : base(shellContext, shellItem)
{
this.shellContext = shellContext;
}

public override void SetAppearance(
BottomNavigationView bottomView,
IShellAppearanceElement appearance
)
{
base.SetAppearance(bottomView, appearance);

var backgroundDrawable = new GradientDrawable();
backgroundDrawable.SetShape(ShapeType.Rectangle);
backgroundDrawable.SetCornerRadius(30);
backgroundDrawable.SetColor(
appearance.EffectiveTabBarBackgroundColor.ToPlatform()
);

bottomView.SetBackground(backgroundDrawable);

if (bottomView.LayoutParameters is ViewGroup.MarginLayoutParams marginLayoutParams)
{
var margin = 30;
marginLayoutParams.BottomMargin = margin;
marginLayoutParams.LeftMargin = margin;
marginLayoutParams.RightMargin = margin;
bottomView.LayoutParameters = marginLayoutParams;
}

}

protected override void SetBackgroundColor(
BottomNavigationView bottomView,
Color color
)
{
base.SetBackgroundColor(bottomView, color);

bottomView.RootView?.SetBackgroundColor(
shellContext.Shell.CurrentPage.BackgroundColor.ToPlatform()
);
}
}
}

Page XAML Example (shows black area under TabBar):



Expected Behavior:

Margin and rounded corners apply only to the TabBar

Navigation bar and page layout remain unchanged

TabBar appears as a floating element

Page background (red) extends under the TabBar without showing black

Actual Behavior:

Margin affects both the TabBar and the navigation/root background

Creates unwanted spacing above the TabBar

Page content does not extend under the TabBar; a black background is visible

Reference:
Based on this tutorial: [Customizing .NET MAUI Shell](https://vladislavantonyuk.github.io/articles/Customizing-.NET-MAUI-Shell/)

Question / Discussion:

Is this the expected behavior of BottomNavigationView inside MAUI Shell, or is there a recommended way to isolate styling changes so they apply only to the TabBar without affecting the navigation layout or page background?

### Steps to Reproduce

Reference to Reproduce:
Based on this article: [Customizing .NET MAUI Shell](https://vladislavantonyuk.github.io/articles/Customizing-.NET-MAUI-Shell/)

Expected Behavior:

Margin and rounded corners apply only to the TabBar

Navigation bar and page layout remain unchanged

TabBar appears as a floating element

Page background (red) extends under the TabBar without showing black

Actual Behavior:

Margin affects both the TabBar and the navigation/root background

Creates unwanted spacing above the TabBar

Page content does not extend under the TabBar; a black background is visible

### Link to public reproduction project repository

_No response_

### Version with bug

10.0.10

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

_No response_

### Affected platforms

Android

### Affected platform versions

Android 15

### Did you find any workaround?

_No response_

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start with the CustomShellHandler and CustomShellBottomNavViewAppearanceTracker code shown in the issue, then reproduce the behavior from the linked Customizing .NET MAUI Shell tutorial on Android 15. Compare the BottomNavigationView margin and background behavior with the page's red background; done means TabBar styling is isolated, navigation layout spacing is unchanged, and no black area appears beneath the TabBar.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.