36

I'm struggling with the dumbest thing (I guess I'm just not used to the Xamarin Designer).

How can I remove the title of my app ? It keeps showing up but it is not in my Layout Source.

I want to remove this whole part but can't figure out how.
In C# Winforms or WPF I would have selected the whole window or screen and then accessed the main window properties but in this case, I can only select the controls I added (buttons and labels) and not the whole screen or the title.

enter image description here

SeyedPooya Soofbaf
  • 2,654
  • 2
  • 29
  • 31
phadaphunk
  • 12,785
  • 15
  • 73
  • 107

14 Answers14

37

Write this in the OnCreate method just after SetContentView:

ActionBar.Hide(); 
SeyedPooya Soofbaf
  • 2,654
  • 2
  • 29
  • 31
23

As far as I remember, in your Activity Class you have to remove the Attribute label there so that it won't have a title. I currently don't have Xamarin with me right now but I'm pretty sure there is an attribute above the class name that sets the Title.

UPDATE from phadaphunk:

Remove android:theme="@android:style/Theme.NoTitleBar" from the manifest file will completely remove the title

UPDATE

NavigationPage.SetHasNavigationBar(this, false);

At the time I wrote the answer, the best answers that are given now are available to the framework. Correct me if I'm wrong but I don't remember those API being available at the time of this writing.

123 456 789 0
  • 10,565
  • 4
  • 43
  • 72
10

Don't change it in Title theme, it will accept previous version ui. After OnCreate

   protected override void OnCreate(Bundle bundle)
   {
        base.OnCreate(bundle); //
        Window.RequestFeature(WindowFeatures.NoTitle); //This will Hide the title Bar
   }

Alternatively, you could add

 NavigationPage.SetHasNavigationBar(this, false);

to your constructor

Jaime Torres
  • 10,365
  • 1
  • 48
  • 56
10

The option which to me seems the simplest is to edit the Activity attribute and use a default style (rather than a custom one, as suggested by Mina Fawzy):

[Activity(Theme = "@android:style/Theme.DeviceDefault.NoActionBar", ...)]

If you want to remove the status bar too then use

[Activity(Theme = "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen", ...)]
Peter Taylor
  • 4,918
  • 1
  • 34
  • 59
  • Peter Taylor, you just saved me!! I am developing in Xamarin, and I have done everything recommended on Xamarin forums, at Microsoft, etc. but it was your recommendation that finally worked! THIS: [Activity(Theme = "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen", ...)] is what worked for me. I added that theme to the parent TAG in my styles.xml and it finally made my SplashScreen activity work perfectly. THANK YOU! – anthony_s Apr 13 '21 at 17:00
4

You can achieve that by create custom style:

<style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

         <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/colorPrimary</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <!-- colorAccent is used as the default value for colorControlActivated,
             which is used to tint widgets -->
        <item name="colorAccent">@color/colorAccent</item>
    </style>

And here how you can use it in your activity:

  [Activity(Label = "ActivityLabel", Theme = "@style/AppTheme")]
halfer
  • 19,824
  • 17
  • 99
  • 186
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156
3
NavigationPage.SetHasNavigationBar(this, false);

Is the best method.

Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
Ibrahim
  • 949
  • 3
  • 12
  • 21
1

In my case I dont't need any Title, I just want an ActionBar with some Tabs so I wrote:

RequestWindowFeature(Android.Views.WindowFeatures.ActionBar);

And after SetContentView:

ActionBar.Title = "";
ozahorulia
  • 9,798
  • 8
  • 48
  • 72
Marian
  • 37
  • 7
0

This worked for me:SupportActionBar.SetDisplayShowTitleEnabled(false);

Maria
  • 77
  • 5
  • 13
  • 1
    if you want to hide `ActionBar` completely just `SupportActionBar.Hide()`, no other option worked for me. The Activity also has `ActionBar` property which was null in my case maybe because I'm deriving my Activity from `AppCompatActivity` – mohas Sep 19 '18 at 15:12
  • 2021 None of these solutions are working! – user1034912 Sep 23 '21 at 09:11
0

To remove the title bar, I just changed the "Style.xml" file:

Add this line in below other items:

<item name="windowNotitle">true</item>

This will remove the title bar from the "AppTheme", you can also create a custom theme next to it in and set it in your activity.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Penibya
  • 1
  • 1
0

[2021] You can set the theme as following:

[Activity(Label = "@string/app_name", Theme = "@style/Theme.AppCompat.Light.NoActionBar", MainLauncher = true)]
Kebechet
  • 1,461
  • 15
  • 31
0

Just add this to app style (Resources/values/styles.xml):

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

Should look like:

<resources>
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
</resources>
0

Just put this NavigationPage.HasNavigationBar="False"under your ContentPage

It works in the latest versions

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 28 '22 at 12:01
-1

Lots of expectable answers!

However, just in case if it's still not working because let's say you're setting custom views. Try ActionBar.Title = null;

tfont
  • 10,891
  • 7
  • 56
  • 52
-1

SupportActionBar.Hide(); worked to hide the entire title bar for me.

Zachucks
  • 158
  • 14