4

When I click the app icons and start to run the apps, it will appear a white screen for 1 sec.
I don't know why.
Is there any idea to clear this white screen and directly go to my activity?

jjLin
  • 3,281
  • 8
  • 32
  • 55

7 Answers7

10

The white/black screen is the window background image.

The window background is shown while e.g. your onCreate() runs and your layouts are being inflated. It can take some time especially if there's a lot of bitmaps that need to be read, decoded and scaled.

Changing the theme works because some themes have a non-default window background. For example, Theme.Wallpaper has a transparent background. There are other definitions there, too. Essentially what you want is:

<style name="YourTheme">
  <item name="android:windowBackground">@null</item>
</style>

Programmatically you can achieve the same with

getWindow().setBackgroundDrawable(null);

at the top of activity onCreate().

(Old question but got bumped up by another answer and there wasn't a good answer.)

laalto
  • 150,114
  • 66
  • 286
  • 303
4

Settings. File>Settings>Build,Deployment>Instant Run Deselect all options shown there.

and add below line in your style.xml

    <item name="android:windowDisablePreview">true</item>
 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowDisablePreview">true</item>
</style>
apply changes in AndroidMainfest.xml
 <application
        android:theme="@style/AppTheme">
Patel vaishu
  • 156
  • 5
3

After I change style.xml:

<resources>

    <style name="AppTheme" parent="android:Theme.Wallpaper" />

</resources>

it works!! Thanks all

jjLin
  • 3,281
  • 8
  • 32
  • 55
1

Add the following in the manifest file of the corresponding activity

 android:launchMode="standard"

and remove android:label="@string/app_name" from the corresponding activity ,this actually helped me

sharath yadhav
  • 546
  • 5
  • 5
0

In your manifest.xml file remove the line android:theme="@style/AppTheme" for your app. and check it again

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
0

Use this tag in your manifest:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Praveen
  • 55,303
  • 33
  • 133
  • 164
JRE.exe
  • 801
  • 1
  • 15
  • 28
0

In Styles add the following things

    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">true</item>

Hope this will help you and its working for me

Priya
  • 177
  • 1
  • 2
  • 10