Kirill Rakhman
Kirill Rakhman

Reputation: 43861

White background during app launch

I want to get rid of the white color during the short period when my app is launching but the content isn't displayed, yet.

My main activity is using a style (from the Manifest) that extends @style/Theme.Sherlock.Light.DarkActionBar with the background set to <item name="android:background">@android:color/transparent</item>. Nowhere in my layout do I use a white background color, yet it appears for a brief moment during app launch.

In the HierarchyViewer I exported the layers and checked back that there is really no white solid in the layout hierarchy.

What setting controls the background color before the layout is drawn? Thanks.

Upvotes: 13

Views: 10114

Answers (3)

BurtK
BurtK

Reputation: 1046

Or you can use drawable. I created a theme for my spash screen like as below :)

<style name="SceneTheme.Light.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="SceneTheme.Light.NoActionBar.Transparent.StatusBar" parent="SceneTheme.Light.NoActionBar">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowBackground">@drawable/bg_splash</item>
</style>

Upvotes: 0

Krishna
Krishna

Reputation: 1634

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>
</style>

Upvotes: 0

Andrii Chernenko
Andrii Chernenko

Reputation: 10204

There's another background attribute in your theme - windowBackground, and you implicitly set it to white by inheriting your style from @style/Theme.Sherlock.Light.DarkActionBar (notice the .Light. part in the name).

You can either use dark version of theme or set it explicitly by including windowBackground in your style definition:

<item name="android:windowBackground">@color/your_color</item>   

Upvotes: 40

Related Questions