0

In my onCreate() method, I use this code to remove the status bar:

// Remove the status bar from the top
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Yet when I start up the app, I can still see the status bar for like a second. How can I prevent this?

Luke Taylor
  • 9,481
  • 13
  • 41
  • 73

2 Answers2

1

Add the following attribute to the activity in the manifest:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
MRD
  • 7,146
  • 1
  • 21
  • 21
  • Thank you, this works! This leads to a new question, why does it take so long to create? There's a black screen until finally the app is create. – Luke Taylor Jun 09 '12 at 18:47
  • I think that applying a theme to the activity shouldn't do it slower. Didn't you have this black screen problem before applying the theme? Normally, how much time does it takes until the view appears will depend just on what you are doing before setting the content view. – MRD Jun 09 '12 at 18:55
  • Yes, I have had this before. I initialize a few objects, that's all, yet it takes up to one second. I guess that's normal then. – Luke Taylor Jun 09 '12 at 19:18
  • If you copy the code maybe I can help. It's a good idea if you display a splash screen or a loading spinner while the initialization is done. In that way the user knows something is going on and the responsiveness feeling is better. – MRD Jun 09 '12 at 19:25
  • Thanks, I'm only displaying a splash screen after the black screen, which I'll better change. :) – Luke Taylor Jun 09 '12 at 20:35
  • I've started a new thread http://stackoverflow.com/questions/10967532/android-splash-screen-before-black-screen about the black screen and the splash screen. – Luke Taylor Jun 10 '12 at 09:11
1

you must use requestWindowFeature before setting the content view

Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36