How can I remove white screen which appear before splash screen?

独自空忆成欢 提交于 2020-03-19 03:30:09

问题


While opening java file I first look blank white screen, and after that it appears me splash screen layout. I have java file as:

new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    //Task 
                    finish();
                }
              }, ARG_SPLASH_TIME);

And in xml file I simply put ImageView and set android:src value. In manifest file I open Splash activity in Launcher Mode.


回答1:


Finally got my answer Splash Screen in Right Way. I do just following.

In values->styles.xml I created splash screen background image

<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
</style>

For below api 19, in values-19->styles.xml I used

<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

I removed setContentview() from SplashActivity and added style for splash screen in Manifest.xml file android:theme="@style/AppTheme.Splash"




回答2:


Well the white screen is a way for android to make system feel more responsive to user. User taps app and instantly is seeing a result (app).

So how we can change this behawior?

We can disable this preview, as @Piyush wrote:

<item name="android:windowDisablePreview">true</item>

Hovewer this will make your app feel slugish instead, i mean, u will not see anything for a while and then u will see your activity, not really an result u would expect to happen.

Better option is to use in your styles for activity.

<item name="android:windowBackground">@drawable/bg</item>

This will change default background for your application, u can put preloader image for an app, for example with your logo.

User in both situation must wait, but this feels much more responsive




回答3:


This is a strange issue with newly released Android Studio. First time of launching application take longer than usual(looks white). This issue happens only in debug mode and not effect to your released APK. Also I was suffering this issue and found this solution.

Settings/Preferences→ Build, Execution, Deployment → Instant Run and uncheck Instant Run

Instant run in Android Studio 2.0 (how to turn off)




回答4:


Use :

<item name="android:windowDisablePreview">true</item>

in your style.xml file for your app theme.




回答5:


You can use this style in your splash activity-

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


来源:https://stackoverflow.com/questions/40905317/how-can-i-remove-white-screen-which-appear-before-splash-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!