问题
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