I am making a game in LibGDX, and I have noticed that when my game is launched a black screen is shown for a few moments before the white screen of my game is drawn.
I have set the background of my app's theme to be a different color with android:windowBackground
in my app's style.xml, and the preview window shows that color. However, right before the main screen of my app loads, the screen goes black for a moment before displaying the main screen.
I've tried setting Gdx.gl.glClearColor(1,1,1,1)
in the main activity and Game class of my game, but the black screen still shows for a moment before drawing the main screen.
The only way I've found to fix this is to set the android:windowDisablePreview
to true, but that disables the preview window all together.
Is there any way to fix this without disabling the preview?
In addition to shifting objects creation to constructor, you also need to shift the ApplicationListener object creation in Activity class's constructor.
The black screen is probably because of the time delay between start of Activity.onCreate() call and end of ApplicationListener.show() call.
Try to measure it using a timer or simply System.currentTimeMillis() so the difference would be visible.
This should improve the situation if not eliminate the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With