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 ); |
Thanks this was helpfull
[Reply]
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:
March 28th, 2009 at 9:32 am
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:
April 30th, 2009 at 12:39 pm
For me, FLAG_NO_STATUS_BAR doesn’t exit.
So I tried FLAG_FULLSCREEN instead.
Hope it will work for you too.
[Reply]
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:
June 1st, 2009 at 5:16 pm
Thank you for your update.
[Reply]
Anon Reply:
December 14th, 2009 at 3:55 am
yes! thanks for the update!!!
[Reply]
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]
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]
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]
Put
android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”
in the activity attributes.
and put
outside application declarations.
[Reply]
i dont know how to use it, please somebody tell me what should i do, step by step, i am a newbie,,, heheheh,,,
[Reply]
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]
Gr8 it worked for me, thanks guys
[Reply]