912

I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can't simply set the theme to @android:style/Theme.NoTitleBar.

Using the NoTitleBar theme as a parent for my style would remove the title bar from all of my activities.

Can I set a no title style item somewhere?

Irfan S
  • 177
  • 3
  • 12
Janusz
  • 176,216
  • 111
  • 293
  • 365

37 Answers37

1081

Do this in your onCreate() method.

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here); 

this refers to the Activity.

Ziem
  • 6,059
  • 7
  • 49
  • 83
YaW
  • 12,012
  • 3
  • 17
  • 21
  • 8
    Great answer. You don't have to do both though, removing the notification bar may be overkill. – Jim Blackler Apr 07 '10 at 10:11
  • 211
    Be certain to put it *before* the call to setContentView(R.id.x), otherwise it will crash. The reason wasn't immediately obvious to me. 08-13 12:47:33.561 E/AndroidRuntime( 9125): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.SplashActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content – mobibob Aug 13 '10 at 17:51
  • 9
    You should really mention that when using requestWindowFeature(), a force-close will occur if you execute this line after adding **any** content. And on a side note, the XML method is much safer and it also separates page structure from your code, (which is the _entire_ purpose of the XMLs in the first place.) – b1nary.atr0phy Feb 16 '12 at 18:57
  • 2
    the XML / theme method is inferior as it resets the entire theme of your app. i.e., if you are on honeycomb+, doing what others have suggested with android:theme will reset the theme for your entire app to non-holo. – Jeffrey Blattman Jun 19 '12 at 21:09
  • Great answer [+1] .... One thing i had to cast like this to resolve my issue .... this.requestWindowFeature((int) Window.FEATURE_NO_TITLE); – Devrath Apr 26 '14 at 07:21
  • Used this solution on Marshmallow and the title flashes on the screen before the activity has fully loaded. – AndroidDev Sep 27 '15 at 18:58
  • 22
    This doesn't work using API 22. I still see the title bar initially as the app boots. – user2966445 May 13 '16 at 14:12
  • 12
    it works if your activity extends Activity NOT AppCompatActivity i.e. your class should be declared as public class myActi extends Activity {} – Manpreet Singh Dhillon Nov 19 '17 at 04:39
  • true.... i agree with you @ManpreetSinghDhillon, But i wonder why did the android team didn't just provide a toggle, showTitleBar = true / false for simplicity purposes in general? – gumuruh Oct 04 '20 at 06:41
537

You can modify your AndroidManifest.xml:

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">

or use android:theme="@android:style/Theme.Black.NoTitleBar" if you don't need a fullscreen Activity.

Note: If you've used a 'default' view before, you probably should also change the parent class from AppCompatActivity to Activity.

schlenger
  • 1,080
  • 1
  • 14
  • 35
Redax
  • 9,011
  • 6
  • 29
  • 39
  • How come this theme isnt't present in my project? Code completion doesn't show @android.. – Vincent Mar 31 '11 at 14:21
  • 1
    I don't know why. I have only used the default project and added an activity. The autocompletion my not work, but the theme is there. – Redax Apr 02 '11 at 13:53
  • 1
    There are lots of places where code completion doesn't work, it improved greatly in latest (juni 2011) updates of Android Dev Tools but there's still a lot of work to be done! – Sander Versluys Jun 23 '11 at 09:02
  • 83
    `android:theme="@android:style/Theme.Black.NoTitleBar"` is probably more useful unless you're making a game – Chris S Oct 31 '11 at 19:41
  • 7
    Or to light theme. – Fernando JS Oct 24 '13 at 18:06
  • 22
    I don't know why, but this is crashing my app. Any help? – Akeshwar Jha Dec 03 '15 at 07:24
  • 13
    @Akeshwar: You might have to mess with your styles.xml file. For example, change – Brit Clousing Oct 19 '16 at 23:30
  • @BritClousing if you mess with the styles.xml file there is no need to modify the AndroidManifest anymore. At least, this was the case to prevent my crash. – MwBakker Sep 17 '18 at 12:28
  • I tried it, and I got `java.lang.RuntimeException: Unable to start activity ComponentInfo{...} android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819)` – jmamath Jan 20 '20 at 17:26
398

I now did the following.

I declared a style inheriting everything from my general style and then disabling the titleBar.

<style name="generalnotitle" parent="general">
    <item name="android:windowNoTitle">true</item>
</style>

Now I can set this style to every Activity in which I want to hide the title bar overwriting the application wide style and inheriting all the other style informations, therefor no duplication in the style code.

To apply the style to a particular Activity, open AndroidManifest.xml and add the following attribute to the activity tag;

<activity
    android:theme="@style/generalnotitle">
Mark McKenna
  • 2,620
  • 1
  • 14
  • 16
Janusz
  • 176,216
  • 111
  • 293
  • 365
  • I get -> Error retrieving parent for item: No resource found that matches the given name 'general' when trying this css. Could you give me a hint why this is? – Vincent Mar 31 '11 at 14:22
  • 14
    I believe he created a style called "general" and he's just extending it. Just remove it for your own use. – rcl Apr 28 '11 at 21:47
  • 7
    +1 for answering the question, rather than just specifying the most obvious way to achieve similar results like most of the other answers on this question do. It's just a shame you had to answer your own question to get an accurate answer... – Jules Feb 27 '13 at 07:29
  • 1
    this answer is the best.even you can use any other theme provided by android with no title bar. Thanks a lot for sharing – Narendra Pal Apr 15 '13 at 08:39
  • 5
    I belive this is more elegant solution than programmatic this.requestWindowFeature(Window.FEATURE_NO_TITLE); because in this case some "blinking" of title still visible – abovesun Dec 03 '13 at 19:20
  • 1
    Best answer to OP question :) But still that doesn't remve title bar on my activity (API19) – 1111161171159459134 Jun 17 '15 at 16:30
  • Works for me when I used just "windowNoTitle" instead of "android:windowNoTitle" – iforce2d Apr 24 '20 at 12:04
166

I don't like the this.requestWindowFeature(Window.FEATURE_NO_TITLE); because the title bar appears briefly, then disappears.

I also don't like the android:theme="@android:style/Theme.NoTitleBar" because I lost all of the 3.0+ Holo changes that the users of the new devices have gotten used to. So I came across this solution.

In your res/values folder make a file called styles.xml (If it doesn't already exist). In that file place the following code:

<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>

Next create a res/values-v11 with another styles.xml file (Once again this may already exist). In that file place the following code:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="Theme.Default" parent="@android:style/Theme.Holo"></style>
    <style name="Theme.NoTitle" parent="@android:style/Theme.Holo.NoActionBar"></style>
    <style name="Theme.FullScreen" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen"></style>
</resources>

And if you are targeting 4.0+, create a res/values-v14 folder with yet another styles.xml file (Yes it may already be there). In that file place the following code:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="Theme.Default" parent="@android:style/Theme.Holo.Light"></style>
    <style name="Theme.NoTitle" parent="@android:style/Theme.Holo.Light.NoActionBar"></style>
    <style name="Theme.FullScreen" parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"></style>
</resources>

Finally, with all of these files created, open your AndroidManifiest.xml file you can add the code:

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

to the activity tag of the activity you want no title for or the application tag if you want it to apply to the entire application.

Now your users will get the themes associated with their device version with the screen layout you desire.

P.S. Changing the value to android:theme="@style/Theme.FullScreen" will have the same effect, but also remove Notification bar.

Devin Stewart
  • 2,865
  • 1
  • 14
  • 20
  • They..this works fine for what you have told, but the images got shrieked when changing the themes. So what to do ??? – Arun Oct 24 '13 at 05:04
  • 1
    @arun - I have not had any image issues using this method. What do you mean by shrieked? – Devin Stewart Oct 25 '13 at 02:28
  • @DevinStewart ...Sorry. I have solved that issue...Your answer was very useful.... Thanks – Arun Oct 25 '13 at 04:52
  • 2
    Best answer.. this.requestWindowFeature(Window.FEATURE_NO_TITLE); is not suitable and true do lost original theme..Thanks @DevinStewart ..accept +1 for your explanation :) – lynndragon Feb 24 '14 at 04:39
  • Nice answer! Unfortunately it breaks when using the compatibility support libs. The compatibility libs require the use of Theme.AppCompat. I'll tinker around to see if I can make it work... – SMBiggs Aug 31 '14 at 11:54
  • 5
    Ah, silly me! I was using the ActionBarActivity, which doesn't make sense if you want to REMOVE THE ACTIONBAR! Changing to a simple Activity or FragmentActivity allows this nice solution to work like a charm. – SMBiggs Aug 31 '14 at 12:03
  • @ScottBiggs your "silly me!" comment helped me more that solutions listed here. I also had ActionBarActivity :) – Misha Akopov Nov 10 '14 at 05:45
  • Didn't work for me - not sure what I did wrong so I've plumped for `this.requestWindowFeature(Window.FEATURE_NO_TITLE);` – noelicus Jul 02 '16 at 14:24
  • 2
    "Unfortunately YourApp has stopped." – Chris Allinson Mar 26 '17 at 16:08
107

The title bar can be removed in two ways as mentioned on the developer Android page:

In the manifest.xml file:

  1. Add the following in application if you want to remove it for all the activities in an app:

    <application android:theme="@android:style/Theme.Black.NoTitleBar">
    
  2. Or for a particular activity:

    <activity android:theme="@android:style/Theme.Black.NoTitleBar">
    
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
whiteShadow
  • 1,152
  • 1
  • 7
  • 11
  • 15
    It's better to use android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" instead of black.theme. Let device handle the theme. but thanks, I used your approach – Varand Pezeshkian Sep 12 '12 at 19:55
63

the correct answer probably is to not extend ActionbarActivity rather extend just Activity


if you still use actionbar activity seems this is working:

@Override
protected void onCreate(Bundle savedInstanceState) {          
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide(); //<< this
    setContentView(R.layout.activity_main);
}

seems this works too:

styles.xml:

   <style name="AppBaseTheme" parent="Theme.AppCompat.Light" >
          <item name="android:windowNoTitle">true</item>   <!-- //this -->     
   </style>

i could do like as Scott Biggs wrote. this kind of works. except there is no theme then. i mean the settings menu's background is transparent:

just change

public class MainActivity extends ActionBarActivity {

to Activity or FragmentActivity

public class MainActivity extends Activity  {

however i could make it look good enough using material design and not remove the actionbar: https://gist.github.com/shimondoodkin/86e56b3351b704a05e53

  1. set icon of application
  2. set colors of action bar to match design.
  3. set icon to settings menu
  4. add more icons (buttons on top)

it is by example of material design compatibility actionbar styling.

Shimon Doodkin
  • 3,676
  • 29
  • 33
53

what works for me:

1- in styles.xml:

 <style name="generalnotitle" parent="Theme.AppCompat.Light" >
          <item name="android:windowNoTitle">true</item>   <!-- //this -->     
   </style>

2- in MainActivity

@Override
protected void onCreate(Bundle savedInstanceState) {          
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide(); //<< this
    setContentView(R.layout.activity_main);
}
  1. in manifest inherit the style:

    <activity android:name=".MainActivity" android:theme="@style/generalnotitle">
    
Flowra
  • 1,244
  • 2
  • 14
  • 19
  • Like described above, sometimes it doesn't work from xml. I do not know why exactly, i'm not completely sure, but `getSupportActionBar().hide();` within onCreate(){} will do the job – ZeePee Nov 23 '19 at 12:34
  • thanks a lot, this is the clear and simplest answer – Siwei Jun 08 '20 at 02:47
43

If you use this.requestWindowFeature(Window.FEATURE_NO_TITLE) user will still be able to see the title bar just for a moment during launch animation when activity starts through onCreate. If you use @android:style/Theme.Black.NoTitleBar as shown below then title bar won't be shown during launch animation.

<activity 
    android:name=".MainActivity" 
    android:label="My App"
    android:theme="@android:style/Theme.Black.NoTitleBar"
    android:screenOrientation="portrait">

above example will obviously override your existing application theme, if you have existing theme then add <item name="android:windowNoTitle">true</item> to it.

raj c
  • 439
  • 4
  • 3
  • My Activity is Single Instance with @android:style/Theme.Black.NoTitleBar but using this code work will when Activity Created First time as you known SingleInstance Activity then Again not Created so it just use OnNewItent Method But now my Problem is when Activity Show it's just Show Status Bar for 4 Second .How i can get out of this.Here is my question Link is http://stackoverflow.com/questions/9308767/in-camera-activity-that-set-as-theme-notitlebar-fullscreen-in-manifest-work-fine – Herry Feb 16 '12 at 11:25
33

when i tried to use all those high upvoted answers my app always crashed. (i think it has something to do with the "@android:style"?)

The best solution for me was to use the following:

android:theme="@style/Theme.AppCompat.NoActionBar"

No header / title bar anymore. Just place it in the <application>...</application> or <activity>...</activity> depending if you (don't) want it in the whole app or just a specific activity.

TryToSolveItSimple
  • 803
  • 1
  • 14
  • 22
17

Create a theme as below.

 <!-- Variation on the Light theme that turns off the title -->
<style name="MyTheme" parent="android:style/Theme.Black">
    <item name="android:windowNoTitle">true</item>
</style>
sandy
  • 3,346
  • 4
  • 35
  • 45
16

Just use getActionBar().hide(); in your main activity onCreate() method.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Anas Al Hamdan
  • 724
  • 1
  • 5
  • 16
16

Add

<item name="android:windowNoTitle">true</item>

inside AppTheme (styles.xml)

nijas
  • 1,839
  • 2
  • 14
  • 13
16

For AppCompat, following solution worked for me:

Add new theme style with no action bar in your styles.xml and set parent="Theme.AppCompat.NoActionBar".

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorPrimary</item>

</style>


Now implement the same theme style to your splash screen activity in androidManifest.xml

<activity
        android:name=".ActivityName"
        android:theme="@style/SplashTheme"> // apply splash them here 

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

Here is result:

enter image description here

Krunal
  • 68,602
  • 40
  • 230
  • 241
15

You just need to change AppTheme style in Style.xml if you replace the definition from DarkActionBar

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

to NoActionBar

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

the AppTheme defined in AndroidManifast.xml

Phiter
  • 12,987
  • 14
  • 45
  • 77
Daniel Levi
  • 291
  • 4
  • 12
13

In your onCreate method, use the following snippet:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
mad_greasemonkey
  • 767
  • 2
  • 9
  • 29
Mahesh
  • 2,832
  • 2
  • 28
  • 41
12

You can use this code in your java file

add this line before you set or load your view

requestWindowFeature(Window.FEATURE_NO_TITLE); 
setContentView(R.layout.activity_main);
Aneh Thakur
  • 968
  • 10
  • 18
11

Add both of those for the theme you use:

    <item name="windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
android developer
  • 106,412
  • 122
  • 641
  • 1,128
11

Add this style to your style.xml file

 <style name="AppTheme.NoActionBar">
     <item name="windowActionBar">false</item>
     <item name="windowNoTitle">true</item>
 </style>

After that reference this style name into your androidManifest.xml in perticular activity in which you don't want to see titlebar, as like below.

<activity android:name=".youractivityname"
     android:theme="@style/AppTheme.NoActionBar">
</activity>
No one
  • 1,082
  • 11
  • 21
9

I'm using a support widget Toolbar v7. So, in order to be able to delete or hide the Title we need to write this.

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);

//Remove¡ing title bar
getSupportActionBar().setDisplayShowTitleEnabled(false);
MontDeska
  • 1,417
  • 18
  • 15
9

To Hide both Title and Action bar I did this:

In activity tag of Manifest:

android:theme="@style/AppTheme.NoActionBar"

In Activity.java before setContentView:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

i.e.,

//Remove title bar

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

NOTE: You need to keep these lines before setContentView

Shailendra Madda
  • 16,925
  • 14
  • 71
  • 115
  • I'm not so experienced in Java or creating Android apps, so your comment that those lines of code should be located before setContentView is what really helped! Thanks! – Kyle van Til Jan 23 '18 at 12:17
8

I believe there is just one line answer for this in 2020

Add the following line to the styles.xml

<item name="windowNoTitle">true</item>
Charlie
  • 18,636
  • 7
  • 49
  • 75
7

Or if you want to hide/show the title bar at any point:

private void toggleFullscreen(boolean fullscreen)
{
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    if (fullscreen)
    {
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    }
    else
    {
        attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    }
    getWindow().setAttributes(attrs);
}
cprcrack
  • 14,411
  • 6
  • 75
  • 83
7

In my case, if you are using android studio 2.1, and your compile SDK version is 6.0, then just go to your manifest.xml file, and change the following code:

Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.lesterxu.testapp2">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

And here is the snip shoot(see the highlight code): enter image description here

Lester
  • 992
  • 14
  • 21
7

This Solved my problem

In manifest my activity:

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

In style under "AppTheme" name:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme"
        parent="Theme.AppCompat.Light.NoActionBar">
        **<item name="windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>**
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>
Paul Roub
  • 35,100
  • 27
  • 72
  • 83
Sam
  • 5,467
  • 4
  • 31
  • 37
6

First answer is amphibole. here is my explain: add:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

in oncreate() method.

before:

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);

(not just before setContentView) if don't do this u will get forceclose. +1 this answer.

David
  • 1,867
  • 19
  • 32
5

This is how the complete code looks like. Note the import of android.view.Window.

package com.hoshan.tarik.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
    }
}
Tarik
  • 9,314
  • 1
  • 19
  • 35
5

Add theme @style/Theme.AppCompat.Light.NoActionBar in your activity on AndroidManifest.xml like this

<activity
        android:name=".activities.MainActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
    </activity>
Samuel Ivan
  • 2,258
  • 19
  • 11
5

I would like to prefer:-

  • AppTheme (Whole app theme)
  • AppTheme.NoActionBar (theme without action bar or toolbar)
  • AppTheme.NoActionBar.FullScreen (theme without action bar & without status bar)

Theme style like:-

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorDarkPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.NoActionBar.FullScreen" parent="AppTheme.NoActionBar">
    <item name="android:windowFullscreen">true</item>
</style>

Also put below code after super.onCreate(savedInstanceState) in onCreate menthod

super.onCreate(savedInstanceState)    
this.window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN)
Rahul
  • 159
  • 1
  • 3
  • 11
4

If you do what users YaW and Doug Paul say, then you have to have in mind that window features must be set prior to calling setContentView. If not, you will get an exception.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
fergerm
  • 221
  • 3
  • 4
4

I found two reasons why this error might occur.

One. The Window flags are set already set inside super.onCreate(savedInstanceState); in which case you may want to use the following order of commands:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);      

super.onCreate(savedInstanceState);

Two. You have the Back/Up button inside the TitleBar, meaning that the current activity is a hierarchical child of another activity, in which case you might want to comment out or remove this line of code from inside the onCreate method.

getActionBar().setDisplayHomeAsUpEnabled(true);
Dzhuneyt
  • 7,039
  • 11
  • 56
  • 108
4

add in manifiest file ,

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

add following line into ur java file,

  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Kunal Dharaiya
  • 121
  • 1
  • 3
4

I am using Android Xamarin and this worked for me.

SupportActionBar.Hide();
SetContentView(Resource.Layout.activity_main);
jase
  • 197
  • 1
  • 13
3

Simply change the parent tag of your App theme to "Theme.AppCompat.Light.NoActionBar"

Cloy
  • 2,051
  • 18
  • 30
2

There are mentions of it in this post but no one explicitly addresses it, so maybe this will save people some time. If you are like me and have multiple classes extending one root class which extends ActionBarActivity, it may not be immediately obvious that trying to set that activity to a NoTitleBar/NoActionBar will throw an error, specifically:

"You need to use a Theme.AppCompat theme (or descendant) with this activity"

You can fix this changing the extends to Activity.

farnett
  • 450
  • 2
  • 6
  • 17
  • If you need "AppCompatActivity" extended class you can instead do `android:theme="@style/Theme.AppCompat.NoActionBar"` in your activity to remove the title bar aka ActionBar, so no need to change your class file – bmatusiak May 04 '16 at 23:46
1

Ahem, you can apply themes to individual activities in XML such as no title. In other words, take it out of your application tag, open the tag declaration and put it in the desired activity tag.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Fred Grott
  • 3,454
  • 1
  • 21
  • 18
  • 3
    That means I have to apply the theme to all my activities but the one that has no title and then recreate my theme without a titlebar and set it to the activity with the missing title? – Janusz Apr 12 '10 at 07:44
1

I used the solution from @YaW to remove the title and notification from my Activity. But, the title and notification would appear when showing a dialog. So, to apply this to a dialog, subclass the dialog as shown below:

public class MyDialog extends android.app.Dialog{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);

        setContentView(R.layout.mydialog);
    }    
}
Chris Sprague
  • 1,789
  • 22
  • 16
0

WindowManager.LayoutParams in Android Studio documentation says FLAG_FULLSCREEN is "Window flag: hide all screen decorations (such as the status bar) while this window is displayed." so this flag does not make my content fill the whole screen.

Lawn
  • 41
  • 1