Adding a splash screen to your app can be done in a five-step process
Table of Contents
Add a background_color.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/black" />
</shape>
Add splashscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/background_color"/>
<item>
<bitmap android:gravity="center"
android:src="@drawable/prestissimo_logo_green"/>
</item>
</layer-list>
Add themes.xml
<style name="SplashTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="android:statusBarColor">@color/pg_green</item>
</style>
Add new activity: SplashScreenActivity.kt & activity_splash_screen.xml
package de.creatronix.levelup
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class SplashScreenActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startActivity(Intent(this, MainActivity::class.java))
finish()
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreenActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
Add new activity to AndroidManifest.xml
<activity
android:name=".SplashScreenActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>






