Skip to content

Instantly share code, notes, and snippets.

@DaChelimo
Created April 2, 2021 08:29
Show Gist options
  • Save DaChelimo/26464c1f7dbe8e5776295253ecd517ac to your computer and use it in GitHub Desktop.
Save DaChelimo/26464c1f7dbe8e5776295253ecd517ac to your computer and use it in GitHub Desktop.
How to create splash screen
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation"
android:label="@string/app_name" />
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setUpStatusBarAndNavigationBar()
}
override fun onStart() {
val intent = Intent(applicationContext, MainActivity::class.java)
startActivity(intent)
finish()
}
}
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:statusBarColor" tools:targetApi="lollipop">@color/dark_theme_blue</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:navigationBarColor" tools:targetApi="lollipop">@color/dark_theme_blue</item>
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@color/dark_theme_blue</item>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment