dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.71k forks source link

Unable to hide NavigationBar #23567

Closed wulean closed 1 month ago

wulean commented 1 month ago

Description

.net8.0 之後似乎無法透過 NavigationPage.HasNavigationBar="False" 來隱藏 NavigationBar

Android/MainActivity.cs

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);
    this.Window.AddFlags(WindowManagerFlags.Fullscreen);
}

Steps to Reproduce

  1. 新增一個 .NET MAUI Blazor應用程式
  2. 使用 .net 8.0
  3. NavigationPage.HasNavigationBar="False" 加入 MainPage.xaml
  4. 執行 Android模擬器

Link to public reproduction project repository

No response

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

7.0.100

Affected platforms

Android

Affected platform versions

Android 14.0

Did you find any workaround?

Relevant log output

未命名

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 1 month ago

This issue has been verified using Visual Studio 17.11.0 Preview 3 (8.0.70 & 8.0.61 & 8.0.10). Can repro it.

JesseIngles commented 1 month ago

What you're trying to hide is the status bar, which is not possible. You can customize your status bar color, by using Maui.CommunityToolkit package resources

wulean commented 1 month ago

@JesseIngles Thanks for your suggestion, but it doesn't seem to work if I add BackgroundColor="{DynamicResource PageBackgroundColor}" to the xml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:myApps"
             x:Class="myApps.MainPage"
             NavigationPage.HasNavigationBar="False"
             NavigationPage.HasBackButton="False"
             Shell.NavBarIsVisible="False"
             Shell.TabBarIsVisible="False"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <BlazorWebView x:Name="_blazorWebView" HostPage="wwwroot/index.html" UrlLoading="Handle_UrlLoading">
        <BlazorWebView.RootComponents>
            <RootComponent Selector="#app" ComponentType="{x:Type local:Main}" />
        </BlazorWebView.RootComponents>
    </BlazorWebView>

</ContentPage>
jfversluis commented 1 month ago

As pointed out this is not the navigation bar but the status bar. You can influence this color either with the .NET MAUI Community Toolkit functionality or set the color in Platforms/Android/Resources/values/colors.xml