white background for few seconds before splash screen android

谁说我不能喝 提交于 2019-12-11 12:35:39

问题


I facing a problem while launching the app. A white background is displayed for a few seconds at first start up, then at second start up sometime it doesn't appears.

I used this in my AppTheme

<item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowBackground">@drawable/my_app_background</item>

I am successful but it shows the my_app_background image inside the app also instead of white background

My current AppTheme

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    </style>

Splash Screen

public class SplashScreen extends AppCompatActivity{

    // Splash screen timer
    public static int SCREEN_TIMEOUT=3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screen);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                Intent intent = new Intent(SplashScreen.this, MainActivity.class);
                startActivity(intent);
                finish();

                Toast.makeText(SplashScreen.this,"Message",Toast.LENGTH_SHORT).show();
            }
        }, SCREEN_TIMEOUT);

    }
}

回答1:


put this in your manifest file:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"



回答2:


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

** put this line in your style it prevents opening white screen before splash



来源:https://stackoverflow.com/questions/32907475/white-background-for-few-seconds-before-splash-screen-android

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