> For the complete documentation index, see [llms.txt](https://boltuix.gitbook.io/material-uix-kotlin-material-design-ver-1.1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boltuix.gitbook.io/material-uix-kotlin-material-design-ver-1.1/integrations/splash-screen.md).

# Splash Screen

Step-by-Step Integration Guide&#x20;

**Add the dependency in your build.gradle file:**

AndroidX Core Library: The primary requirement is to include the AndroidX Core library, which contains the SplashScreen API.

```groovy
  
dependencies {
    // 📱 Include the AndroidX Core library with SplashScreen API support
    implementation "androidx.core:core-splashscreen:1.0.0"
    
    // 🛠️ Add other dependencies as needed for your project
    // implementation "androidx.appcompat:appcompat:1.3.1"
    // implementation "com.google.android.material:material:1.4.0"
}
  
```

**Step 1:** 🎨Setting Up Your Splash Screen Theme

* 🎨 Define a custom theme in your res/values/styles.xml.
* 🎨 Set the background color to match your app’s branding.
* 🎨 Specify the animated icon to be displayed during the splash screen.
* ⏱️ Set the animation duration to control how long the splash screen stays visible.
* 🎨 Post-splash screen theme: Define the theme your app will use after the splash screen is dismissed.

*res/values/splash.xml* (light mode)*res/values-night/splash.xml* (dark mode)

```xml
  
    <resources>
        <style name="Theme.AnimatedSplash.MySplash" parent="Theme.SplashScreen">
            <item name="windowSplashScreenBackground">@color/white</item>
            <item name="windowSplashScreenAnimatedIcon">@drawable/logo</item>
            <item name="windowSplashScreenIconBackgroundColor">@color/white</item>
            <item name="windowSplashScreenAnimationDuration">1000</item>
            <item name="postSplashScreenTheme">@style/Theme.CartUIX</item>
        </style>
    </resources>
  
```

..\
**Step 2:** 💻 Implementing the Main Activity

* 🔧 Install the splash screen using *installSplashScreen()* in *onCreate()*.
* 📱 Enable edge-to-edge display for a modern, immersive UI.
* 🛠️ Set the content view to your main activity layout.
* 🎯 Handle window insets to properly adjust UI components based on system bars.

*java/com/shopping/cart/MainActivity.kt*

```kotlin
  
package com.shopping.cart

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        // 🚀 Install the splash screen and set the condition to keep it on screen
        installSplashScreen().setKeepOnScreenCondition { false }
        
        super.onCreate(savedInstanceState)
        
        // 🌐 Enable edge-to-edge display for a modern UI look
        enableEdgeToEdge()
        
        // 🖼️ Set the content view to the main activity layout
        setContentView(R.layout.activity_main)

        // 🖱️ Apply window insets to adjust for system bars (like status and navigation bars)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }
}
  
```

**..Step 3:** 🖼️ Designing the Logo

* 🖌️ Create a vector drawable for your logo to ensure scalability and performance.
* 📏 Ensure the icon size is set to 192dp for optimal display on the splash screen.
* 📐 Follow guidelines for adaptive icons if you're using a background with the icon.

*res/drawable/logo.xml*<br>

```xml
  
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:aapt="http://schemas.android.com/aapt"
        android:width="276.5dp"
        android:height="306dp"
        android:viewportWidth="276.5"
        android:viewportHeight="306">
      <path
          android:pathData="M187.83,105.76l-8.25,0c-1.32,-17.52 -15.37,-31.42 -32.43,-31.42c-17.13,0 -31.17,13.9 -32.43,31.42L107.42,105.76c-8.63,0 -15.68,7.31 -15.68,16.4l0,23.45c0,0.46 -0.38,0.86 -0.82,0.86l0,0c-4.35,0 -8.06,3.56 -8.12,8.04c-0.06,4.61 3.46,8.37 7.87,8.37l16.44,0c2.52,0 4.6,2.17 4.6,4.81l0,0c0,2.64 -2.08,4.81 -4.6,4.81L79.33,172.49c-4.35,0 -8.06,3.56 -8.12,8.04c-0.06,4.61 3.46,8.37 7.87,8.37l28.02,0c2.52,0 4.6,2.17 4.6,4.81l0,0.59c0,2.64 -2.08,4.81 -4.6,4.81L97.4,199.1c-6.23,0 -11.52,5.14 -11.65,11.73c-0.06,3.36 1.26,6.32 3.34,8.56c2.08,2.17 4.91,3.49 8,3.49l61.65,0c0.57,0 1.2,-0.07 1.76,-0.13l27.33,0c8.63,0 15.62,-7.31 15.62,-16.34L203.45,122.09C203.51,113.07 196.52,105.76 187.83,105.76zM130.09,105.76c1.2,-8.7 8.38,-15.35 17.07,-15.35c8.63,0 15.81,6.72 17,15.35L130.09,105.76zM172.66,203.45c0,1.58 -1.2,2.83 -2.71,2.83l-41.44,0c-3.53,0 -6.36,-2.96 -6.36,-6.65l0,-4.15l29.66,-42.16l-25.19,0c-1.51,0 -2.71,-1.25 -2.71,-2.83l0,-8.3c0,-1.58 1.2,-2.83 2.71,-2.83l37.59,0c4.09,0 7.43,3.49 7.43,7.77l0,4.15l-28.84,41.04L169.95,192.32c1.51,0 2.71,1.25 2.71,2.83L172.66,203.45z">
        <aapt:attr name="android:fillColor">
          <gradient 
              android:startX="72.4"
              android:startY="148.58"
              android:endX="204.66"
              android:endY="148.58"
              android:type="linear">
            <item android:offset="0" android:color="#FFB621FE"/>
            <item android:offset="0.16" android:color="#FFB325FE"/>
            <item android:offset="0.31" android:color="#FFA930FE"/>
            <item android:offset="0.46" android:color="#FF9943FD"/>
            <item android:offset="0.6" android:color="#FF825DFC"/>
            <item android:offset="0.75" android:color="#FF657FFB"/>
            <item android:offset="0.88" android:color="#FF42A9FA"/>
            <item android:offset="1" android:color="#FF1FD1F9"/>
          </gradient>
        </aapt:attr>
      </path>
      <path
          android:pathData="M127.25,123.94m-4.72,0a4.94,4.72 90,1 1,9.45 0a4.94,4.72 90,1 1,-9.45 0"
          android:fillColor="#383838"/>
      <path
          android:pathData="M170.58,123.94m-4.72,0a4.94,4.72 90,1 1,9.45 0a4.94,4.72 90,1 1,-9.45 0"
          android:fillColor="#383838"/>
    </vector>
  
```

**..Step 4:** 📚 Long Description: How to Integrate the SplashScreen API\
The Android SplashScreen API, introduced in Android 12, offers a streamlined way to enhance the launch experience of your app. By leveraging this API, you can display a branded splash screen with animations, providing a smooth transition into your app.\
[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYRX7toKb11OUC8xKL43nVW5ZunkxZx7jkldGW5p5GTfF-Wrr9llBUglzPyD5YKoEcOpq8IlWaQVSIhdsId7ByF9H_zUhz9o2gEjDTlv5GzXNvI93hN7YBackowq4SI6-XpXBm6kNI1REygAp8kOvmGhZ-r9tXEcFLk-6knQrwyFTIPtO1cynvuVm0TOE/s320/boltuix%20splash.png)](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYRX7toKb11OUC8xKL43nVW5ZunkxZx7jkldGW5p5GTfF-Wrr9llBUglzPyD5YKoEcOpq8IlWaQVSIhdsId7ByF9H_zUhz9o2gEjDTlv5GzXNvI93hN7YBackowq4SI6-XpXBm6kNI1REygAp8kOvmGhZ-r9tXEcFLk-6knQrwyFTIPtO1cynvuVm0TOE/s2400/boltuix%20splash.png)\
\
\
🚀 Why Use a Splash Screen in Your App:

* 📱 Brand Identity: Reinforces brand recognition immediately.
* ⏳ Visual Feedback: Shows that the app is loading, improving perceived speed.
* 🌟 First Impressions: Creates a polished, professional first impression.
* ⚙️ Initialization: Utilizes loading time effectively, keeping users engaged.
* 🔄 Seamless Transition: Smoothly transitions users into the main app.

\
**Usage:**&#x4C;aunch / Splash screens can be displayed upon an app’s launch from the home screen when an app loads, instead of displaying a blank screen. \
Displaying a launch screen can decrease the sense of a long load time, and has the potential to add delight to the user experience.\
Launch screens shouldn’t be displayed if an app is running.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://boltuix.gitbook.io/material-uix-kotlin-material-design-ver-1.1/integrations/splash-screen.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
