How to Hide the Title Bar in Android

An activity with title bar removed
No Title Bar – eBay Fee Calculator

How do you hide the title bar on an application in Android? I have seen this question over and over again. As a developer, you must use the small screen size very wisely when laying out your app. Yes, new phones come with a bigger screen size nowadays but still you need to make sure that all users who can potentially download your app are able to use it.

So, depending on what kind of an app you are developing, gaining few pixels by removing the title bar can go long way. I am sure if you are developing a game, you will appreciate every extra pixel you can get which in turn will improve user experience.

You can remove or hide the title bar or status bar from your activity in two ways. The one way I have used in almost all my apps is through WindowManager in an activity. It is very simple and you only need to import android.view.Window and write one line of code. WindowManager has other few features that can help you customize the look and appearance of your activity window.

Here’s how you can remove or hide title bar applied in an activity.

What if I have my own custom title? I am glad you asked. You can set custom title to an activty if you have one made in your layout resource. Following along the same lines, first you will have to request window feature as shown above and then you have to call the custom title from resources. I will show you how to create a custom title in the future.

Again, here’s hide or remove title bar by setting a custom title.

It is very important that requestWindowFeature() is made before setContentView(). If the feature request is made after, the default title will remain in place. Also, it is worth to mention that both FEATURE_NO_TITLE and FEATURE_CUSTOM_TITLE cannot be used with any other Window features because the default title is completely replaced.

The second way that you can use to remove status bar from window is by applying custom theme in the manifest file. Custom theme can be applied to a selected activity or the entire application. I will not go into how to create custom themes today but if you have one in place, you can easily apply in the manifest file as follows. Assuming style.xml is the file inside resources folder with “noStatusBar” and “noTitleBar” theme names.

Apply custom theme to remove status bar and hide title bar on individual activities.

That’s it for today. I hope this tutorial will shed some light on how to hide title bar and help you customize your activity’s title bar or status bar.

This entry was posted in Android Development Tutorials and tagged , , , , , . Bookmark the permalink.

Comments are closed.