How to remove (Android) app title bar in Xamarin.Forms?

10,540

Solution 1

If you want to remove the title bar on the initial page, the quickest and easiest way to do it is to go to to the contentpage heading in your XAML for the page and type

NavigationPage.HasNavigationBar="False"

so the XAML would like something like this

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="YourClass.YourPage"
             NavigationPage.HasNavigationBar="False">

Solution 2

This can be done in PCL:

 var page = new LoginPage();
 NavigationPage.SetHasNavigationBar(page, false); // call this method every time before you push a page (no title bar)
 await navigation.PushAsync(page); 

If you are using old FormsApplicationActivity, try, add this in OnCreate(Bundle bundle) method

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle)

    Forms.SetTitleBarVisibility(AndroidTitleBarVisibility.Never);
    Forms.Init(this, bundle);
}

This one seems do the app wide setting, but I am not so sure, as I don't use FormsApplicationActivity anymore.

Solution 3

Using the latest version of Xamarin.Forms I found that if you use:

await Navigation.PushAsync(new NextPage())

//Title on NextPage is displayed

await Navigation.PushModalAsync(new NextPage())

//Title on NextPage is not displayed

Nathan

Solution 4

i had this problem before and my solution was adding this line of code to the MainPage.xaml NavigationPage.HasNavigationBar="False"

<?xml version="1.0" encoding="utf-8" ?>
<xf:BottomBarPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:xf="clr-namespace:BottomBar.XamarinForms;assembly=BottomBar.XamarinForms"
                  xmlns:local="clr-namespace:App;assembly=App"
                         NavigationPage.HasNavigationBar="False" <-- This line !-->
                  x:Class="App.MainPage">

and it worked for me !

Share:
10,540

Related videos on Youtube

Szandi
Author by

Szandi

Updated on September 16, 2022

Comments

  • Szandi
    Szandi over 1 year

    Is there any chance that I can remove the title bar of the app in Xamarin.Forms? I am working on a Xamarin.Forms Portable project. I tried a lot of solutions, but neither worked, I couldn't even start the app.

    First attempt I tried adding this to my AndroidManifest.xml, didn't work:

    android:theme="@android:style/Theme.NoTitleBar"
    

    Second attempt I tried creating a styles.xml in Resources/values, which was:

    <?xml version="1.0" encoding="utf-8" ?>
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
      <style name="Theme.Default" parent="@android:style/Theme"></style>
      <style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
      <style name="Theme.FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
    </resources>
    

    And then I added this to my AndroidManifest.xml (didn't work either)

    android:theme="@style/Theme.NoTitle"
    

    Third attempt I tried adding this to my OnCreate method in MainActivity.cs (didn't work).

    RequestWindowFeature(WindowFeatures.NoTitle);
    

    Can anyone help me with this?

  • Szandi
    Szandi almost 8 years
    I'm not sure where I have to insert this code. Could you tell me where I should? I mean which file and which place (e.g. App.cs -> public App() method)