Search code examples
androidmaui

How do I remove this secondary "title bar" above the navigation bar on MAUI Android?


I'm currently working on migrating our app to MAUI. This bar recently appeared when I switched back to Android after spending a few days fixing iOS issues. During which I upgraded to the latest version .NET 9 via visual studio updates and the latest MAUI.Controls packages. I have tried rolling back the MAUI.Controls to the 9.0 release (same version which I have an old Android build of that works as expected) but it doesn't let me remove it again now. I haven't changed anything in my styles since this did work either.

I have asked this question here but it got dismissed as not a bug and the suggested solution from the MAUI devs doesn't work for me.

I'd like to know what this bar is! The white bar in the screenshot is the navigation bar and this can be hidden as expected using the normal HasNavigationBar property, but the new "Title" bar that appears above it I don't seem to be able to control with anything.

There is a repo project on the GitHub post for anyone interested.

MAUI screenshot


Solution

  • This is what solved it for me

    You change the theme in MainActivity, search for line base.SetTheme(Resource.Style.MainTheme)

    Remove this line, and the extra bar will go away

    The Maui.SplashTheme inherits from Maui.MainTheme.NoActionBar, so by using base.SetTheme(Resource.Style.MainTheme), and not base.SetTheme(Resource.Style.MainTheme_NoActionBar)` you reenables the action bar

    see: https://github.com/dotnet/maui/blob/2e4ca4a4d16017fcafbf16d07e6f299456004fff/src/Core/src/Platform/Android/Resources/values/styles.xml#L37