Android: Setting Window Background on launched Activity

So I’ve read Romain Guy’s blog post on setting the Window background and percieved performance, and am trying to emulate that. It is such a simple solution and not sure why I can’t get this working, but the activity simply refuses to pick-up the directed background.

I have a ListView that onListItemClick launches a new Activity, one that takes 3-5 seconds to fully load. While the user is waiting, I’d like to draw a windowBackground so that they ‘see’ the activity before it is actually ready. Here’s my code:

  • Communicating directly between two mobile devices
  • Adb shell commands to change settings or perform tasks on a phone
  • AudioRecord: start() status -38
  • Android Studio - remove Security Exception warning
  • Where do I find the Google Play Services attribution text?
  • How to delete an SMS from the inbox in Android programmatically?
  • AndroidManifest snippet for the launched Activity:


    The XML layout for the EditorActivity:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android=""
        android:text="Editor" />

    And finally, the drawable being set in the Manifest, background_editor.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <bitmap xmlns:android=""
        android:tileMode="repeat" />

    editor_bg is a .png file located int he drawable folder.

    The end result is the EditorActivity gets launched, and all I see is the default black background with the “Editor” text displayed in white (I added that to test that the XML file was loading correctly.

    I’ve also tried setting the background of the FrameLayout and TextView to transparent via android:background=”@android:color/transparent”, thinking maybe they were defaulting to a black background, but no luck.

    It’s been a long few days, I’m sure I am missing something simple… any obvious mistakes I am making here?

    Related posts:

    Add floating point value to android resources/values
    Android: Generate random color on click?
    Why declare a function argument to be final?
    Optimising Android application before release
    Android Pre Compiler error?
    Android will not generate in Eclipse
  • Paste from AccessibilityService works in API22 does not work in API17
  • Error installing Android app with Spotify SDK,
  • How to hide Android status bar in native game written with gomobile
  • 'sourceSets' cannot be applied to 'groovy.lang.closure' warning in Android Studio
  • Android Studio, Gradle, OpenCV and NDK
  • How to output messages to the Eclipse console when developing for Android
  • 3 Solutions collect form web for “Android: Setting Window Background on launched Activity”

    Try setting window background before launching the new activity programmatically.


    I have ran into the same problem and wasted my day on it. We can’t set the theme in java as in my case the control came to onCreate of my splash activity very late. Till that time black screen keep visible.

    This gave me clue that window has to be managed from theme which we specify in manifest.

    There is the manifest i have:

                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

    Now The theme i created is as follows:

    <style name="Splash" parent="@style/Theme.AppCompat.Light">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimaryDark">@color/green_09</item>
        <item name="colorPrimary">@color/green_09</item>
        <item name="windowActionBar">false</item>

    Splash in the drawable resource which contains a bitmap resource, I have to tweak a bit to make it look perfect not stretched and in center:

    <bitmap xmlns:android=""
        android:src="@drawable/splash_screen" />

    it works for me if i declared this in a Theme Style in styles.xml :

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:android=""   
        <style name="CustomTheme" parent="android:Theme.Holo.NoActionBar">
            <item name="android:windowBackground">@color/bg_evening</item>

    and in the manifest i set this theme to my application :

        android:theme="@style/CustomTheme" >

    or to one of my activities :


    you can declare muliple theme styles and add any one of them to any of your activities, which will override the theme set to the application

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.