Whenever I launched my app, it displayed a blank screen for a few seconds before displaying the splash screen.
Now it displays a purple background(from my drawable) for a few seconds before displaying the splash screen(after I added the "what I tried code"). What I want to do is to completely remove the screen that displays before the splash screen. Like I want the splash screen to be displayed immediately I open the app, please how can I fix this?
Here's my code:
MainActivity.java:
public class MainActivity extends AppCompatActivity {
Animation topAnim, bottomAnim;
ImageView image;
TextView logo, slogan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
setContentView(R.layout.activity_main);
topAnim = AnimationUtils.loadAnimation(this,R.anim.top_animation);
bottomAnim = AnimationUtils.loadAnimation(this,R.anim.bottom_animation);
image = findViewById(R.id.imageView);
logo = findViewById(R.id.textView);
slogan = findViewById(R.id.textView2);
image.setAnimation(topAnim);
logo.setAnimation(bottomAnim);
slogan.setAnimation(bottomAnim);
int SPLASH_SCREEN = 5000;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, HomeActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_SCREEN);
}
}
styles.xml:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#0347F4</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/purple_background</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">shortEdges</item>
</style>
</resources>
What I have tried:
I tried to fix it adding this to the styles.xml:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/purple_background</item>