How to disable action bar permanently

AndroidAndroid Actionbar

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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" ... />

Solution 2 - Android

By setting activity theme in Manifest,

<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
....
>

Solution 3 - Android

I use the following code inside my onCreate function:

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

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

Solution 4 - Android

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

maybe this help you

Solution 5 - Android

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 {

Solution 6 - Android

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" 

Solution 7 - Android

Go to styles.xml Change this DarkActionBar to NoActionBar

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

Solution 8 - Android

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    getSupportActionBar().hide();
}

Solution 9 - Android

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

Solution 10 - Android

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

Solution 11 - Android

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.

Solution 12 - Android

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

Solution 13 - Android

Under res -> values ->styles.xml

Change

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

To

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

Solution 14 - Android

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>

Solution 15 - Android

Type this code to your onCreate method before setContentView:

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

Solution 16 - Android

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.

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

Solution 17 - Android

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.

Solution 18 - Android

in the onCreate function add the following code

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

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

Solution 19 - Android

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.

Solution 20 - Android

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>

Solution 21 - Android

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

Solution 22 - Android

There are two ways to disable ActionBar in Android.

requestWindowFeature(Window.FEATURE_NO_TITLE); 
setContentView(R.layout.activity_main); 

Solution 23 - Android

try this in your manifist

 <activity
        android:name=".MainActivity"
        android:theme="@android:style/Theme.Holo.NoActionBar"
        android:label="@string/app_name" >

Solution 24 - Android

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

Solution 25 - Android

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.

Solution 26 - Android

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.

Solution 27 - Android

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.

Solution 28 - Android

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>

Solution 29 - Android

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)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBijiView Question on Stackoverflow
Solution 1 - AndroidmonchoteView Answer on Stackoverflow
Solution 2 - AndroidBijiView Answer on Stackoverflow
Solution 3 - AndroidrscView Answer on Stackoverflow
Solution 4 - AndroidsemihView Answer on Stackoverflow
Solution 5 - AndroidPiotr MüllerView Answer on Stackoverflow
Solution 6 - Androidreza.cse08View Answer on Stackoverflow
Solution 7 - AndroidDr AdamsView Answer on Stackoverflow
Solution 8 - AndroidRajarshee MitraView Answer on Stackoverflow
Solution 9 - AndroidnoobView Answer on Stackoverflow
Solution 10 - AndroidTrixie BelarminoView Answer on Stackoverflow
Solution 11 - AndroidHoang Nguyen HuuView Answer on Stackoverflow
Solution 12 - Androidsanket vetkoliView Answer on Stackoverflow
Solution 13 - Androiduser8231406View Answer on Stackoverflow
Solution 14 - AndroidodlhView Answer on Stackoverflow
Solution 15 - Androidpavel_coderView Answer on Stackoverflow
Solution 16 - AndroidRavi ChandraView Answer on Stackoverflow
Solution 17 - AndroidVarun VedView Answer on Stackoverflow
Solution 18 - AndroidRahulView Answer on Stackoverflow
Solution 19 - AndroidRaif DeariView Answer on Stackoverflow
Solution 20 - AndroidMohsen EmamiView Answer on Stackoverflow
Solution 21 - AndroidAvinash RView Answer on Stackoverflow
Solution 22 - AndroidgauravView Answer on Stackoverflow
Solution 23 - AndroidMrad4TechView Answer on Stackoverflow
Solution 24 - AndroidAbhijeetView Answer on Stackoverflow
Solution 25 - AndroidLorenzo BarbagliView Answer on Stackoverflow
Solution 26 - AndroidwhyozView Answer on Stackoverflow
Solution 27 - AndroidJohn Melody MeView Answer on Stackoverflow
Solution 28 - AndroidAviroxiView Answer on Stackoverflow
Solution 29 - AndroidJayantkumarView Answer on Stackoverflow