Howto set FULL SCREEN on Android

If you only want to remove the title bar, add this line to onCreate() method of your activity:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

If you want to set your activity to use the whole display screen, which means also remove the status bar, you need to add one more line:

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NO_STATUS_BAR,
WindowManager.LayoutParams.FLAG_NO_STATUS_BAR);

Reference: http://groups.google.com/group/android-developers/msg/1d7497e5626896a7
Note: It’s for SDK-M3, the flag name changed in SDK-M5.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
 
public class FullScreenActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NO_STATUS_BAR,
        		WindowManager.LayoutParams.FLAG_NO_STATUS_BAR);
        setContentView(R.layout.main);
    }
}

Thanks to Ace’s comment. The code should be changed to

1
2
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                    WindowManager.LayoutParams.FLAG_FULLSCREEN );

About Evan

Comments

15 Responses to “Howto set FULL SCREEN on Android”
  1. Brad says:

    Thanks this was helpfull

    [Reply]

  2. hi there. says:

    Hi there!
    If I add those lines to my program
    WindowManager.LayoutParams.FLAG_NO_STATUS_BAR);

    my touch screen event doesnt’ work any more.
    any reason?
    ken

    [Reply]

    Evan Reply:

    Well, it should works well. You can have a try in a new empty activity. I guess there may be something wrong in your other code.

    [Reply]

    Joonghoon Reply:

    For me, FLAG_NO_STATUS_BAR doesn’t exit.
    So I tried FLAG_FULLSCREEN instead.

    Hope it will work for you too.

    [Reply]

  3. Ace says:

    The flag changed in the new SDK release, this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
    Works for me, thanks.

    [Reply]

    Evan Reply:

    Thank you for your update.

    [Reply]

    Anon Reply:

    yes! thanks for the update!!!

    [Reply]

  4. I’m trying to run a browser window in full-screen but without success. Any suggestion on how to instantiate the webKit in my application in complete full screen?

    [Reply]

  5. Chain Davies says:

    If you want to go full screen without the status bar and title showing briefly at startup you can add a theme in the AndroidManifest xml file

    Add
    android:theme=”@android:style/Theme.Black.NoTitleBar”

    to your activity or the application node depending on you want full screen in your app or only in one activity

    [Reply]

  6. Ian Schillebeeckx says:

    I was having trouble getting fullscreen on xlarge screens. This fix seems to be to set the sdkversion to at least 9. Here’s my xml for fullscreen (don’t need onCreate implementation):

    [Reply]

  7. Ian Schillebeeckx says:

    Put
    android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”
    in the activity attributes.

    and put

    outside application declarations.

    [Reply]

  8. Lana Bahree says:

    i dont know how to use it, please somebody tell me what should i do, step by step, i am a newbie,,, heheheh,,,

    [Reply]

  9. TheMonz says:

    Hi

    I’ve tried this “tips” for a Iconia A500 Honeycomb 3.0.

    It removes the status bar (great)
    but the width is not affect and the button I got, is not filling all the screen… (neither in width or height)

    So, what shall I try ?

    [Reply]

  10. marco says:

    Gr8 it worked for me, thanks guys

    [Reply]

Trackbacks

Check out what others are saying about this post...


Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!