0

I have the following problem:

When I start my activity, its default background is set to white. I can change it in onCreate method. If I use this method to change the background, I have something like 2 seconds of white background every time I start the activity.

Is there any way to have background that I chose (for example black) from the beginning of application life?

Marek
  • 3,935
  • 10
  • 46
  • 70

1 Answers1

1

The best way to handle this would be to modify the Activity's Theme. See: Themes.

Essentially, you should be able to set the background in a custom theme, which would be loaded before any calls to set views.

Edit -

The question has been edited slightly, so the previous answer really only applies to setting the background prior to the call of onCreate. If instead you want something to show while your app loads, you could create a special Theme for the initial Activity, and set that in the Manifest.

Tim C
  • 635
  • 5
  • 18
  • Could I do it in some method instead? Which one could be appropriate? – Marek Jun 11 '13 at 00:47
  • No, if you want it visible before the onCreate runs, then it'll have to be defined in the Manifest via a Theme. As a bonus though, you can define one Theme and apply it to the entire Application should you desire a consistent appearance. Or just to a specific Activity if you just need to adjust one. – Tim C Jun 11 '13 at 00:49
  • See Answer edit. You can use the Theme to set the background to an image or something - essentially creating a "splash" screen while your app loads. – Tim C Jun 11 '13 at 00:52