MAUI Shell.TitleView: Unable to Remove PaddingMargin on iOS and Android - Stack Overflow

admin2025-04-21  2

I am developing a MAUI mobile application and am struggling to customize the header using the Shell.TitleView. The issue is the persistent padding/margin areas around the TitleView that I cannot seem to modify.

Here are the problems I'm encountering:

iOS: There is extra space on the top and both sides of the TitleView that I cannot remove. The areas marked in red in the first image highlight these problematic spaces.

Android: There is extra space on the left-hand side of the TitleView (marked in red in the second image).

Ignore the red boxes in the TitleView. That was just me blocking out my name.

I have tried setting the following properties in XAML and code-behind, but none of them seem to have any effect:

Padding, Margin, HeightRequest, WidthRequest, HorizontalOptions, VerticalOptions

I also attempted modifying the Shell styles and themes but haven't had any success. I don't even want to move content into the area on iOS, I just want to colorize and in Android, I want to colorize and center everything as it's all shifted right.

Has anyone else experienced this issue? If so, how did you resolve it? Any advice or suggestions would be greatly appreciated!

Attached are the images.

Thank you in advance for your help!

iOS Android

I am developing a MAUI mobile application and am struggling to customize the header using the Shell.TitleView. The issue is the persistent padding/margin areas around the TitleView that I cannot seem to modify.

Here are the problems I'm encountering:

iOS: There is extra space on the top and both sides of the TitleView that I cannot remove. The areas marked in red in the first image highlight these problematic spaces.

Android: There is extra space on the left-hand side of the TitleView (marked in red in the second image).

Ignore the red boxes in the TitleView. That was just me blocking out my name.

I have tried setting the following properties in XAML and code-behind, but none of them seem to have any effect:

Padding, Margin, HeightRequest, WidthRequest, HorizontalOptions, VerticalOptions

I also attempted modifying the Shell styles and themes but haven't had any success. I don't even want to move content into the area on iOS, I just want to colorize and in Android, I want to colorize and center everything as it's all shifted right.

Has anyone else experienced this issue? If so, how did you resolve it? Any advice or suggestions would be greatly appreciated!

Attached are the images.

Thank you in advance for your help!

iOS Android

Share Improve this question edited Mar 14 at 11:29 Julian 9,0675 gold badges29 silver badges60 bronze badges asked Jan 23 at 3:02 goodguychadwickgoodguychadwick 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

This is a known issue on the github: [Spec] Shell/NavigationPage TitleView #5063.

And there is a workaround for the Android. Just put the following code in the App class:

        public App()
        {
            InitializeComponent();
            Microsoft.Maui.Handlers.ToolbarHandler.Mapper.AppendToMapping("CustomNavigationView", (handler, view) =>
            {
#if ANDROID
                handler.PlatformView.ContentInsetStartWithNavigation = 0;
                handler.PlatformView.SetContentInsetsAbsolute(0, 0);
#endif
            });
        }

There is no workaround for iOS. But you can refer to the pull request: [iOS] Shell/NavigationPage TitleView.

转载请注明原文地址:http://anycun.com/QandA/1745220114a90420.html