147

I can hide the action bar in honeycomb using this code:

getActionBar().hide();

But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action bar permanently?

Arun J
  • 687
  • 4
  • 14
  • 27
Biji
  • 2,701
  • 3
  • 16
  • 8

29 Answers29

262

If you are using Theme.Holo.Light and want to use the Theme.Holo.Light.NoActionBar variant on pre 3.2 devices you can add this to your styles.xml:

<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style> 

and then set it as your activity's theme:

<activity android:theme="@style/NoActionBar" ... />
monchote
  • 3,440
  • 2
  • 20
  • 20
123

By setting activity theme in Manifest,

<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
....
>
Biji
  • 2,701
  • 3
  • 16
  • 8
  • this seems like the only proper way to do it. esp. if you happen to have a relativelayout at the bottom... – jcfrei Jun 23 '12 at 13:50
  • 1
    This is the only way that I can get to work, unfortunately. It removes custom theming, but it is truly the only thing that fully removes the `ActionBar`, for me. – RileyE May 22 '13 at 18:15
  • 4
    This doesn't work with the enforcement of AppCompat theme in the new ADT. I don't think fighting this - trying to do away completely from AppCompat is good solution either! I've try @monchote's approach and it works for me – ericn May 08 '14 at 02:11
  • this should be instead of – Amandeep Rohila May 20 '15 at 13:11
  • On Samsung Galaxy J2 it makes the app crash but no problems on Nexus 9 – Suici Doga Sep 03 '16 at 06:56
  • deprecated using this / not compatible with app compat – larsaars Jul 02 '20 at 17:20
37

I use the following code inside my onCreate function:

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

Source: https://developer.android.com/guide/topics/ui/actionbar.html

rsc
  • 10,348
  • 5
  • 39
  • 36
  • 1
    The source seems to be outdated as of 2019. Up to date source: https://developer.android.com/training/system-ui/status – B.Cakir Aug 20 '19 at 22:10
31
<application
    .
    .
    android:theme="@android:style/Theme.Holo.Light.NoActionBar"
    . >

maybe this help you

semih
  • 821
  • 8
  • 16
23

With the Android Studio default generated Activity superclass is ActionBarActivity and then, none of solution in other responses works. To solve just change superclass:

public class xxxActivity extends ActionBarActivity{

to:

public class xxxActivity extends Activity {
Piotr Müller
  • 5,323
  • 5
  • 55
  • 82
19

If you want to get full screen without actionBar and Title.

Add it in style.xml

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
      <item name="windowActionBar">false</item>
      <item name="windowNoTitle">true</item>
      <item name="android:windowFullscreen">true</item>
</style>

and use the style at manifest.xml.

android:theme="@style/AppTheme.NoActionBar" 
reza.cse08
  • 5,938
  • 48
  • 39
14

Go to styles.xml Change this DarkActionBar to NoActionBar

style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
Dr Adams
  • 287
  • 4
  • 8
13
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    getSupportActionBar().hide();
}
Rajarshee Mitra
  • 1,876
  • 28
  • 23
12

The best way I found which gives custom themes and no action bar, is to create a SuperClass for all activities in my project and in it's onCreate() call the following line of code -

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

It always work for me. The only issue in this approach is, you'll see action bar for a fraction of second when starting the app (Not the activity, the complete app).

0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184
9

You can force hide the action bar simply:

ActionBar  actionbar = getSupportActionBar();
actionbar.hide();

Just use your default theme, it will work good if fullscreen is set

Pradeep Kumar Kushwaha
  • 2,231
  • 3
  • 23
  • 34
6

Don't use Holo theme and the Actionbar will disappear. This code is working for me on API 8+, with support lib v7:

<style name="NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>

set that theme for your activity:

<activity android:theme="@style/NoActionBar" ... />

and in your activity class.

It works even when it extends ActionBarActivity.

chanklor
  • 487
  • 5
  • 11
Hoang Nguyen Huu
  • 1,202
  • 17
  • 17
6

If you just want a theme with no action bar you can use 'NoActionBar' variant, for eg. if your base theme is as below

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

then you can use

<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

But if you want to retain the properties of your main theme i.e. AppTheme you can do as below

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

You can retain all the properties of your base theme this way and don't have to explicitly add them in your NoActionBar theme :)

sanket vetkoli
  • 826
  • 14
  • 18
6

Under res -> values ->styles.xml

Change

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

To

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

Shubham Shekhar
  • 316
  • 3
  • 17
5

Heres a quick solution.

You find styles.xml and you change the base application theme to "Theme.AppCompat.NoActionBar" as shown below.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
</style>
odlh
  • 431
  • 5
  • 6
4

Type this code to your onCreate method before setContentView:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
pavel_coder
  • 181
  • 2
  • 5
3

Below are the steps for hiding the action bar permanently:

  1. Open app/res/values/styles.xml.
  2. Look for the style element that is named "apptheme". Should look similar to <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">.
  3. Now replace the parent with any other theme that contains "NoActionBar" in its name.

    a. You can also check how a theme looks by switching to the design tab of activity_main.xml and then trying out each theme provided in the theme drop-down list of the UI.

  4. If your MainActivity extends AppCompatActivity, make sure you use an AppCompat theme.

Ravi Chandra
  • 106
  • 1
  • 3
3

I would like to post rather a Designer approach to this, this will keep design separate from your business logic:

Step 1. Create new style in (res->values->styles.xml) : Basically it is copy of your overall scheme with different parent - parent="Theme.AppCompat.Light.NoActionBar"

<!-- custom application theme. -->
    <style name="MarkitTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccent</item>

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

Step 2: In your AndroidManifest.xml, add this theme to the activity you want in: e.g. I want my main activity without action-bar so add this like below:

<activity android:name=".MainActivity"
            android:theme="@style/MarkitTheme">

This is the best solution for me after trying a lot of things.

Varun Ved
  • 339
  • 3
  • 6
2

in the onCreate function add the following code

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

and just import android.support.v7.app.ActionBar

Rahul
  • 45
  • 9
2

Make sure you create a new theme by changing the name of the default theme in the styles.xml file to:

 <style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar">

and than change the theme from the drop-down under your main_activity.xml to whatever you called your theme.

Raif Deari
  • 21
  • 1
2

Use this in styles.xml file:


<style name="MyTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
Mohsen Emami
  • 2,709
  • 3
  • 33
  • 40
1

Another interesting solution where you want to retain the ViewPager while removing the action bar is to have a style as show

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:actionBarStyle">@style/NoActionBarStyle</item>
    <item name="android:windowContentOverlay">@null</item>
</style>
<style name="NoActionBarStyle" parent="android:Widget.Holo.ActionBar">
    <item name="android:backgroundSplit">@null</item>
    <item name="android:displayOptions"></item>
</style>

This is the way most of the Dialer applications in android is showing the ViewPager without the action bar.

Ref: https://github.com/CyanogenMod/android_packages_apps_Dialer

Avinash R
  • 3,101
  • 1
  • 27
  • 47
1

There are two ways to disable ActionBar in Android.

requestWindowFeature(Window.FEATURE_NO_TITLE); 
setContentView(R.layout.activity_main); 
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
gaurav
  • 539
  • 4
  • 2
1

try this in your manifist

 <activity
        android:name=".MainActivity"
        android:theme="@android:style/Theme.Holo.NoActionBar"
        android:label="@string/app_name" >
Mrad4Tech
  • 205
  • 2
  • 12
1
  protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
    setContentView(R.layout.activity_main);
Abhijeet
  • 27
  • 3
0

I use this solution:

in the manifest, inside your activity tag:

android:label="@string/empty_string"

and in strings.xml:

<string name="empty_string">""</string>

This way you keep ActionBar (or Toolbar) with the title, but when Activity if created the title is automatically empty.

Lorenzo Barbagli
  • 1,241
  • 2
  • 16
  • 34
0

Strangely enough, none of these worked for me when building on a Nexus 7 running 4.4.2 (API 19). For the most part, at least with the latest version of Android Studio (1.2.1.1) after creating a blank activity app, the:

android:theme="@style/AppTheme"

is in the application element, not the activity element. If I removed the above code or tried to change it to:

android:theme="@android:style/Theme.Holo.Light.NoActionBar"

the app won't run...if this is happening to you, just go into your styles.xml file (res > values > styles.xml) and add the .NoTitleBar to the end of the parent like this block:

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

No changes to the AndroidManifest file are needed.

whyoz
  • 5,168
  • 47
  • 53
0

In your activity_main.xml, you can adjust from there in the line:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
.......
    android:theme="@style/Theme.Design.Light.NoActionBar"
.......    
">

Sometimes when you can see things like this Click here, You can select from here the "noActionBar" theme.

Hope me helped you.

钟智强
  • 459
  • 6
  • 17
-1

Some answers already been written and if you didn't find styles.xml file in res>values then you can do this go to res>values>themes>themes.xml here you need to add these two lines inside the style

 <item name="android:windowFullscreen">true</item>
 <item name="windowNoTitle">true</item>
Aviroxi
  • 115
  • 1
  • 9
-1

Theme.xml file

 <style name="Theme.FurnitureApp.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>

write the below code before setContent{ } method

requestWindowFeature(Window.FEATURE_NO_TITLE);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0)
Jayant Kumar
  • 775
  • 5
  • 12