2

Sorry, I'm sure this is very basic stuff.

In the activity my app launches to, the XML for my layout is as follows:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background2x"
    android:id="@+id/mainScreen"
    tools:context="com.offyear.www.offyear.WelcomeActivity">

The problem I'm having is that the screen does not load immediately to the background image that I've set. It loads to a blank white screen first for about a half a second before the background image and buttons appear. Granted, this is not breaking my app's functionality or anything, but it's annoying and looks sloppy.

What do I need to do so that there is no initial blank white screen? When my app starts, the first thing the user should see is the background image and buttons.

Thanks, and apologies for the Android 101 question.

TJ Rogers
  • 478
  • 1
  • 5
  • 16
  • You could try [setting translucent theme](http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android) to the activity or you can set this background to theme in manifest. Refer this : http://stackoverflow.com/questions/14307126/black-screen-before-splash-screen-appear-in-android. – Abhishek V Oct 11 '14 at 18:48

1 Answers1

1

Best way to improve performance and "speed" when setting backgrounds is to add whatever you want to have as background to the theme used by your activity. This is because Android draws whatever you have in the theme first and only after that draws your root layout and your background as well.

If you have time, you can check out Cyril Mottier's video about improving your implementation when dealing with drawables. He gives really good tips and advices for these scenarios:

https://www.parleys.com/play/528e806ae4b054cd7d2ef4a5/chapter50/about

Mike
  • 4,356
  • 4
  • 28
  • 45