Как убрать action bar в android studio
Перейти к содержимому

Как убрать action bar в android studio

  • автор:

Android — How to remove the title bar from your application activity

There are three easy ways you can remove the title bar/ action bar from your Android application:

  • Setting the <style> tag parent attribute value inside res/styles.xml file
  • Hide the action bar from activity class using getSupportActionBar().hide() method

Let’s start by learning how to change the styles.xml file

Remove Android title bar from the main themes file

To remove the title bar/ action bar from your Android application, you can set the <style> tag in your application to NoActionBar .

When you create a new Android application using Android Studio, the <style> tag for your application is commonly generated at Project -> app -> src -> main -> res -> values -> styles.xml or themes.xml depending on your Android Studio version.

The content of the XML file looks similar to this:

You just need to change the action bar from DarkActionBar to NoActionBar at line 4 of the code above:

Additionally, you may also have the values-night folder inside the res folder as shown below:

The values-night folder contains another theme.xml that your Android app will use when the user uses the Dark Theme.

You may also want to set the parent attribute of the <style> tag in this theme.xml to NoActionBar to make your application consistent.

Setting the <style> tag to use NoActionBar will remove the title bar from all activities inside your application.

Remove Android title bar from specific activities

When you want to remove the title bar for one particular activity, you need to hide the title bar from the activity class file.

For example, here’s how you can remove the title bar from your MainActivity class:

Note that getSupportActionBar() is available only when your class extends AppCompatActivity . If you’re extending Activity class, you need to call getActionBar() method instead:

If you’re using Kotlin, then set the call to supportActionBar or actionBar as follows:

And that’s how you can remove the title bar from your Android application ��

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!


Sebhastian is a site that makes learning programming easy with its step-by-step, beginner-friendly tutorials.
Learn JavaScript and other programming languages with clear examples.

Free Code Snippets Book

Get my FREE code snippets Book to 10x your productivity here


report this ad

How to hide Action Bar?

In this article, We will see how to hide action bar in android app.

asif ali


The action bar is an important part of the android design element. It provides consistent familiar look across the devices, easy navigation and view switching with tabs and dropdowns and also provides functionality to indicate user’s location in the app.

Although, Action Bar is good and an important feature for android applications, but sometimes we have to hide it in some scenarios. I’ll teach you how to hide the Action Bar. There are several ways to hide the Action Bar and I’ll discuss all possible ways to achieve this.

1) Hide Action Bar permanently from styles.xml

If you want to hide Action Bar throughout the app (Activities, Fragments) everywhere, you can simply navigate to res > values > styles.xml and change your Base application theme as mentioned below.


2) Hide Action Bar for a particular activity:

You can directly hide Action Bar for a specific activity by specifying the NoActionBar theme in its activity tag in the manifest file. For this simply navigate to your projects’ root and open the Android manifest file and add a single line of code as mentioned below.

3) Hide Action Bar with custom Theme:

Sometimes you want to style your app in a custom way, and there is a requirement to hide the Action Bar. A simple and convenient method is to create another style extending the custom theme and add two items to the theme.

Example: If you want to use a theme called Mytheme, You have to create another theme called NoActionBar and add these two lines as follows:

4) Hide Action Bar Programmatically:

We have discussed methods to hide the Action Bar without touching our actual classes as it worked well. However, we can also do the same by adding a few lines of code in our activity class. Let me show you how we can do this from our Activity class. So in our Activity’s onCreate method, you can add the following lines of code.



4) Hide Action Bar using Window Manager

You can set the WindowManager flag alternatively. This approach makes a lot easier to hide or show the Action Bar as a user interacts with your app. Again in your Activity’s onCreate method just add these lines.

Keep in mind you have to specify these particular lines before setContentView() or your app will crash.

That’s it for these tutorials. As we have discussed different approaches to achieve this task and all of the discussed approaches are valid you can choose whatever approach you want to according to your needs.

How To Remove The ActionBar From Specific Activities (Android Studio)

ActionBar is a special and important part of the android app. It is a menu bar that runs across the top of the activity screen in android. Most beginners don’t have enough idea about it.

removed actionbar

You will see an actionbar in every activity when you create an app for the first time. In some activities, we don’t need that. In this article, I am going to show you that how you can remove the actionbar from specific activities and also from all activities.

Remove the ActionBar From Specific Activities

Suppose you are creating an app where you have a splash screen. In that case, we don’t need an actionbar in that splash screen activity. Then you need to remove that actionbar from that specific activity. Here is the step-by-step process to do that.

Step 1: Go to the AndroidManifest.xml file

You can find that by double pressing on the shift key. You can see the file search option in the android studio when you double press on the shift key. Type the file name in the search field and it will show you those files.

Step 2: Find the application tag and activity tag

In the AndroidManifest.xml file, you can see the application tag. Inside the application tag, you can find the activity tag. AndroidManifest.xml file can contain multiple activity tags. It depends on how many activities the developer created during the development process.

Step 3: Find an activity tag for a specific activity

Suppose you have an activity for the splash screen and you want to remove the actionbar for that activity. Check the android:name attributes for each activity tag. If your activity name is MainActivity then the attribute value should be «.MainActivity».

Step 4: Change the theme of the activity

There ate some default themes in Android. You can apply those themes to different activities. In this case, we are going to use «Theme.AppCompat.Light.NoActionBar». This theme is going to remove the actionbar from that activity.

Here is the code that comes default:
Here is the after adding theme:

Here we just added the theme which helps us to make a specific activity actionbar free. Now you can apply this theme to any activity where you don’t want the actionbar. Here is the line of code you have to use in the opening activity tag of an activity.

ActionBar code android studio

Remove the ActionBar From All Activities

Most professional app developers don’t like to use the default ActionBar. The recommendation is to use a toolbar instead of ActionBar. The toolbar is easier to use, fully customizable, can be used for all devices. To remove ActionBar from all activities we have to follow the steps below.

Step 1: Go to styles.xml

Using the double press on shift key method you can find out the styles.xml file. You can manually find this option in the android studio toolbar. Click on the search icon (Search Everywhere) and then type the file name in the search box.

Step 2: Change the AppTheme

If you open the styles.xml file you can see some tags. Find the style tag. The default value of the parent attribute is the dark theme. You have to change that to make all activity ActionBar free. Here is the code for no actionbar:

Replace this line with the default theme code. Now your app has no actionbar in it. This is so much important for us to understand the basics of the actionbar. Practice it and try to implement this on different projects.

Hello, there! I am Sakib Mahmud from Bangladesh. Currently, I am studying computer science and engineering. And I love to write articles. facebook external-link instagram github telegram youtube linkedin

Android Studio — Action Bar remove

I’m trying to remove/disable the ActionBar. I tried to put in the Manifest:

and it doesn’t work. It doesn’t remove the ActionBar. Please help me. Thanks.

iYonatan's user avatar

12 Answers 12

I had this issue too. I went to styles.xml and changed

and that removed it from all my activities.

Ram's user avatar

in your oncreate() method use this

If your minSdkVersion is 10 or lower, instead use:

JoeBilly's user avatar

You can try this. It works for me

Add it in style.xml

and use the style at manifest.xml.

For android studio You can go to styles.xml and change

and in Eclipse it can be changed in manifest file

ASIF ALI's user avatar

I think this should work.

rebatoma's user avatar

Ashikur Rahman's user avatar

You hide action bar by with different ways.

1.action bar hidden through the manifest xml file (non Java Programming), then the easy way is to add the following attribute in Activity tag:

If custom Theme is created then it is convenient to create another style extending the custom theme.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *