I have different Activities
in my App and in all of them I do not want the Action Bar
. I cannot find how to disable it. I have tried to find an attribute to apply it to the main_activity.xml
but so far I did not find anything. Can somebody help me please?

- 1,267
- 1
- 16
- 30

- 1,142
- 2
- 10
- 14
14 Answers
Haha, I have been stuck at that point a while ago as well, so I am glad I can help you out with a solution, that worked for me at least :)
What you want to do is define a new style within values/styles.xml so it looks like this
<resources>
<style name = "AppTheme" parent = "android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name = "NoActionBar" parent = "@android:style/Theme.Holo.Light">
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
</style>
</resources>
Only the NoActionBar style is intresting for you. At last you have to set is as your application's theme in the AndroidManifest.xml so it looks like this
<application
android:allowBackup = "true"
android:icon = "@drawable/ic_launcher"
android:label = "@string/app_name"
android:theme = "@style/NoActionBar" <!--This is the important line-->
>
<activity
[...]
-
4This one didn't help, used http://stackoverflow.com/questions/29790070/upgraded-to-appcompat-v22-1-0-and-now-getting-illegalargumentexception-appcompa instead – Raul Pinto Dec 21 '15 at 10:43
-
3Are you sure it is `item name = "android:windowActionBar"`? I had to use it without `android:` prefix to make it work. See [this answer](https://stackoverflow.com/a/26515159/1000551) – Vadim Kotov Mar 20 '18 at 11:08
-
1This answer is almost 4 years old, there may be something different by now. Thank you for sharing the solution that worked for you though! – JRsz Apr 19 '18 at 02:11
-
1Use
- true
instead of- true
– kunal.c Dec 25 '19 at 10:05 -
1this work for flutter too. – ibrahim saputra Jul 13 '22 at 06:17
There are multiple ways of doing this.
1) Change the theme in Android Manifest
Below the Application element, you will find theme tag. Replace it with this one -
android:theme="@android:style/Theme.NoTitleBar"
If you are using AppCompat, use @android:style/Theme.AppCompat.NoActionBar
.
This will set the theme for all activities. If you don't need the action bar in a specific acitivity, then set the theme in the activity container, ie
<activity android:theme="@android:style/Theme.NoTitleBar" ...>
You may also set android:theme="@android:style/Theme.NoTitleBar"
theme in the styles and use it later on.
2) Create a Custom Theme
Add this in res/values/styles.xml
<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
and then set it as your activity's theme in Manifest:
<activity android:theme="@style/NoActionBar" ... />
3) Dynamically Remove the Action Bar
Put this code in the onCreate
method before setting content view -
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
If you are using the support library use getSupportActionBar()
.
-
This one didn't help, used http://stackoverflow.com/questions/29790070/upgraded-to-appcompat-v22-1-0-and-now-getting-illegalargumentexception-appcompa instead. – Raul Pinto Dec 21 '15 at 10:44
-
That's because you will be using appcompat. Thanks for pointing it out. I have made the changes. – Confuse Dec 21 '15 at 12:33
-
If you're using AppCompat
, declare your activity in AndroidManifest.xml
as follows:
<activity
android:name=".SomeActivity"
...
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

- 677
- 8
- 8
Considering everyone is posting older ways of hiding the ActionBar here is the proper way of implementing it within styles for AppCompat support library. Which I highly suggest moving toward if you haven't already.
Simply removing the ActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
If you are using the appcompat support libraries, this is the easiest and recommended way of hiding the ActionBar to make full screen or start implementing to toolbar within your layouts.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Your Toolbar Color-->
<item name="colorPrimary">@color/primary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight, and colorSwitchThumbNormal. -->
</style>
Then to change your toolbar color
<android.support.v7.widget.Toolbar
android:id=”@+id/my_awesome_toolbar”
android:layout_height=”wrap_content”
android:layout_width=”match_parent”
android:minHeight=”?attr/actionBarSize”
android:background=”?attr/primary” />
Last note: Your Activity class should extend AppCompatActivity
public class MainActivity extends AppCompatActivity {
<!--Activity Items -->
}

- 3,520
- 3
- 22
- 39
-
1Thanks, Eugene H. Well, I tried your code changing colors with random values. It works, as it could work without color definitions. Due to NoActionBar. – CoolMind Sep 12 '15 at 15:43
-
1@CoolMind You are correct. I just added some typical styles attributes with AppCompat. I will add descriptions within the answer. – Eugene H Sep 12 '15 at 16:00
-
-
This is probably the best solution and should be accepted as an answer. It's based on the latest technique available in Android dev studio, thus recommended for use. Kudos to Eugene H. – Alexander Bell Sep 23 '19 at 14:03
Default style you getting in res/value/style.xml like
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And just the below like in your activity tag,
android:theme="@style/AppTheme.NoActionBar"

- 121
- 1
- 3
If you want most of your activities to have an action bar you would probably inherit your base theme from the default one (this is automatically generated by Android Studio per default):
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
And then add a special theme for your bar-less activity:
<style name="AppTheme.NoTitle" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="actionBarTheme">@null</item>
</style>
For me, setting actionBarTheme to @null was the solution.
Finally setup the activity in your manifest file:
<activity ... android:theme="@style/AppTheme.NoTitle" ... >

- 469
- 4
- 6
You may also change inheritance from ActionBarActivity to Activity as written here.
UPDATE
A good solution is here:
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
}
open Manifest and add attribute theme = "@style/Theme.AppCompat.Light.NoActionBar" to activity you want it without actionbar :
<application
...
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
...
</activity>
</application>

- 1,739
- 16
- 21
I will try to show it as simple as i can:
DECLARE FULL SCREEN ACTIVITY IN ANDROID MAINIFEST file:
<activity
android:name=".GameActivity"
android:label="@string/title_activity_game"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
Now in Android studio (if you using it) open your Activity xml file ( in my example activity_game.xml) in designer and select theme (above mobile phone in designer click button with small circle) and then select Mainfest Themes on the left side and then NoTitleBar.Fullscreen.
Hope it will help!
-
You can use android:theme="@style/Theme.AppCompat.Light.NoActionBar" for AppCompat. – atablash Oct 28 '15 at 16:56
Please find the default theme in styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
And change parent this way
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

- 2,285
- 1
- 13
- 16
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
Using this theme worked for me

- 8,426
- 4
- 55
- 63
Put this line in your Activity
in the Manifest
:
<activity android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
...
</activity>
and make sure you didn't put Toolbar
in your layout
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
/>

- 1,005
- 3
- 11
- 22
Create an new Style with any name, in my case "Theme.Alert.NoActionBar"
<style name="Theme.Alert.NoActionBar" parent="Theme.AppCompat.Dialog">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
set its parent as "Theme.AppCompat.Dialog" like in the above code
open AndoridManifest.xml and customize the activity you want to show as Alert Dialog like this
<activity
android:excludeFromRecents="true"
android:theme="@style/Theme.Alert.NoActionBar"
android:name=".activities.UserLoginActivity" />
in my app i want show my user login activity as Alert Dialog, these are the codes i used. hope this works for you!!!

- 281
- 2
- 7
It's Really Simple Just go to your styles.xml
change the parent Theme to either
Theme.AppCompat.Light.NoActionBar
or Theme.AppCompat.NoActionbar
and you are done.. :)

- 1,444
- 2
- 13
- 27

- 3
- 2