Hiding status bar in Xamarin.Forms

Mohammad Radawan 106 Reputation points
2021-11-01T09:54:28.67+00:00

145446-image-048.png

Xamarin.Forms App
How can I hide the highlighted section when I run my App (on android and iOS)
I've already tried (NavigationPage.HasNavigationBar="False") but it didn't work

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,251 Reputation points Microsoft Vendor
    2021-11-02T01:52:35.5+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    If you want to hide the statusbar, please try to following ways.

    For Android, please open MainActivity.cs, add Window.AddFlags(WindowManagerFlags.Fullscreen); and Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen); to the OnCreate method like following code.

       protected override void OnCreate(Bundle savedInstanceState)  
               {  
                   base.OnCreate(savedInstanceState);  
                     
                   //add here  
                   Window.AddFlags(WindowManagerFlags.Fullscreen);  
                   Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);  
         
         
                   Xamarin.Essentials.Platform.Init(this, savedInstanceState);  
                   global::Xamarin.Forms.Forms.Init(this, savedInstanceState);  
                   LoadApplication(new App());  
               }  
    

    For iOS, please open Info.plist by XML(Text) editor, add following key-value pairs(Status bar is initially hidden – Type Boolean – Value Yes
    View controller-based status bar appearance – Type Boolean – Value No) in the <dict> tag.

       <key>UIStatusBarHidden</key>  
       <true/>  
       <key>UIViewControllerBasedStatusBarAppearance</key>  
       <false/>  
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful