How to hide title bar and status bar in Android application

 

This post is going to be very short one and here we will discuss about how to hide title bar and status bar in Android application.

If you look at Gaming applications like ‘Cut the rope’, ‘Angry birds’ and more in your android device,  applications are displayed in full screen view which covers entire area of the display to provide more user experience.

We will develop a sample application which has no title bar and no status bar.

Quick Links

Project Structure

  • Create new android project [File >> New >> Android Project] with project name FullScreenExample
  • Click next and select target android device version [I chose version 2.2]
  • Click next and enter package name – ‘com.prgguru.android’
  • Click finish

Code Listings

We can achieve full screen view in either of the two ways:

  1. Include full screen theme in AndroidManifest XML
  2. Include Window settings in onCreate method of Activity class

Include full screen theme in AndroidManifest  XML:

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

Just change YourClassName to the Activity class name ( in our application it is ‘FullScreenExampleActivity’).

Include Window settings in onCreate method of Activity class:

package com.prgguru.android;

import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

public class FullScreenExampleActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//No title bar is set for the activity
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		//Full screen is set for the Window
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);

		setContentView(R.layout.main);
	}

}

Demo

Congratulations, We are done.
Let us test the application:
Right click on the project >> Run as >> Android application >> Choose emulator or device
You could see this screen:

Download Source Code

Entire project is zipped and is available for download. Unzip the downloaded project and to import the project into eclipse, launch eclipse >> File >> Import.. >> Choose downloaded project(How to import android project in eclipse). If you just want to run the application in your mobile and see the output but don’t want to hit your head with source code, download application(apk) file and install it in your mobile device.

Download Source Code Download Application(apk)

*apk in Android is the installation file simliar to exe in windows.

[pglinkadssmall]

I hope you enjoyed the post!! :)

Suggested posts for further reading


[pgfeedback]
[pgwriteforus]

Related Articles

Author: Android Guru

Share This Post On
  • g.gopikrishna

    is this fullscreen view working on android 4.0 is fine,but this full screen view not working on android 3.2.how to achieve full screen view on android 3.2.please give suggestion to me as early as possible.your example running on andriod 4.0,not in android 3.2……………….

    • Sunghun

      Just use Android Theme.NoTitleBar.FullScreen.

  • g.gopikrishna

    How to hide title bar and status bar in Android application all versions,plaese give suggetion …………………..

    • Hi,
      It is working perfectly in other Android versions.
      Please give a try.

  • g.gopikrishna

    hi,
    how to suppress dictionary hints while entering text in textarea for android…………….

Join now to get more access to our Android Tutorials

Join now to get more access to our Android Tutorials

Once you Join, you will receive Mail containing latest Android Tutorials once a month !!

I promise I wont spam you !!

You have Successfully Subscribed!

Pin It on Pinterest

Shares