Mobile application development begins not with functionality, but with the first impression. It is splash screen (Splash Screen) that is the visual element that the user sees in the first seconds of launching the app. A well-implemented start screen form not only demonstrates the brand logo, but also hides the process of initializing components, creating the feeling of instant operation of the system.

In the environment Android Studio the creation of such a screen can be implemented in various ways: from simple display of a picture to complex animations using vector graphics. Modern Google standards require that the transition between launching an application and its main interface be smooth and free of sudden jumps or โ€œblinkingโ€ white screens.

In this article, we will take a detailed look at the process of creating a professional screensaver using the latest SDK tools. You'll learn how to customize themes, work with resources, and avoid common mistakes that can lead to a poor user experience.

Preparing resources and project structure

Before you start writing code, you need to prepare your graphics assets. Your company or app logo needs to be presented in multiple resolutions to display correctly on devices with different pixel densities. The optimal solution is to use vector graphics SVG, which Android Studio automatically converts to the format VectorDrawable.

The files are placed in a folder res/drawable. It is important to keep the project structure clean to avoid confusion when connecting resources in the code. If you use bitmap images, make sure they are optimized for size, as "heavy" images increase the application's cold start time.

โš ๏ธ Warning: Do not use images with a transparent background for Splash Screen unless your background is a solid color. This may result in rendering artifacts on some devices.

๐Ÿ’ก

Use the WebP format for raster images instead of PNG - this will reduce the size of the APK file by 25-35% without any visible loss of quality.

For working with vector graphics in Android Studio, there is a convenient import tool. You can simply drag the file .svg to the drawable folder, and the system will prompt you to rename it and configure the settings. This ensures that the logo will be clear on high-density screens, such as Retina or Super AMOLED.

Creating a Splash Layout

The next step is to create an XML layout that will describe the arrangement of elements on the screen. For a screensaver, one central element is usually enough - a logo. Create a new layout file in the directory res/layout and name it, for example, activity_splash.xml.

Inside this file we use a container ConstraintLayout or RelativeLayoutto position ImageView strictly in the center. Using constraints ensures that the logo remains centered on the screen regardless of device orientation or display size.

<?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"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/background_color">

<ImageView

android:id="@+id/logo"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/ic_launcher_logo"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Pay attention to the attribute android:background. The background color of the splash screen should match the background color of the application theme so that the transition is invisible. This creates a โ€œnativeโ€ and professional effect.

โ˜‘๏ธ Checking the splash screen layout

Done: 0 / 1

Settings themes and styles

A critical point is to correctly define the topic. If the theme is not configured correctly, the user may see a standard white or black system screen before loading your layout. To avoid this, you need to modify the file themes.xml or create a separate style for the splash screen.

We will create a new style that inherits from the base theme, but overrides the parameter android:windowBackground. This allows you to set the background color and even the image that will be displayed by the system before loading (layout) of the activity.

In the file styles.xml or themes.xml add the following code:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

<item name="android:windowBackground">@drawable/splash_background</item>

<item name="android:statusBarColor">@color/primary_color</item>

</style>

Here we use drawable-resource for the background, which allows you to combine the color and image in one file. This is a more flexible approach than simply specifying a color. It is also important to remove ActionBaras it is usually not needed on the splash screen.

Theme parameter Value Description of influence
windowBackground @drawable/bg Window background before loading layout
statusBarColor @color/black The color of the status bar at the top
navigationBarColor @color/white The color of the navigation bar at the bottom
colorPrimary @color/blue The main color of the UI elements
Why does the white screen blink?

The white screen appears when the theme The activity is not set or the standard light theme is set, and the application takes a long time to load. The system shows the default window background until the first frame of your application is rendered.

Implementing Activity logic

After preparing resources and styles, you need to create an activity class. In modern development on Kotlin or Java this is done by inheriting from AppCompatActivity. In the method onCreate we set our previously created layout.

The main task of this activity is to hold the screen for a while (simulating loading) or wait for background processes to complete, and then switch the user to the main screen. For delay, the method Handler or coroutines is used.

Example implementation in Kotlin:

class SplashActivity: AppCompatActivity {

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

setContentView(R.layout.activity_splash)

Handler(mainLooper).postDelayed({

val intent = Intent(this, MainActivity::class.java)

startActivity(intent)

finish

}, 2000)

}

}

In this code Handler starts the task after 2000 milliseconds (2 seconds). Inside a task is created Intent to go to MainActivity, after which the current activity is closed by the method finish, removing it from the stack.

โš ๏ธ Attention: Never use a delay of more than 3-4 seconds unless really necessary. Users perceive a long splash screen as a sign of a โ€œheavyโ€ and slow application.

Don't forget to register the created activity in the manifest file AndroidManifest.xml. It is here that we will indicate what exactly SplashActivity is the entry point into the application, replacing the standard MainActivity.

Animation of interface elements

A static picture is boring. To spice up your splash screen, add an animation for your logo to appear. In Android, this is done using the animation resources in the folder res/anim. The most popular effects are scale (zoom) and transparency (fade).

Create a file anim_logo.xml and describe the sequence of actions. For example, a logo might fade out of transparency and increase slightly in size. This creates dynamics and attracts attention.

  • ๐ŸŽจ AlphaAnimation: changes the transparency of the object from 0 to 1.
  • ๐Ÿ“ ScaleAnimation: changes the size of the object along the X and Y axes.
  • ๐Ÿ”„ RotateAnimation: rotates the object around the center.
  • ๐Ÿš€ TranslateAnimation: moves the object in screen space.

You need to start the animation after the layout has been fully loaded. In the activity code, use the method startAnimation for your ImageView. Combining several animations AnimationSet allows you to create complex and beautiful effects.

๐Ÿ’ก

Animation should be short (up to 1 second) and smooth. Sudden movements or too long animation irritate the user and create a feeling of interface instability.

Setting up the manifest and launching

The final stage is the correct configuration AndroidManifest.xml. Find the tag <activity>, which is now the main one (has an intent-filter with MAIN and LAUNCHER), and replace its class with yours SplashActivity.

If you are creating a screensaver for the first time, make sure that it does not have unnecessary parameters that may conflict with system settings. In particular, check the android:exportedattribute, which in new versions of Android is required for activities with intent filters.

An example of a correct entry in the manifest:

<activity

android:name=".SplashActivity"

android:exported="true"

android:theme="@style/SplashTheme">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

After making changes to the manifest, be sure to run Rebuild Project. Run the application on an emulator or real device. If everything is done correctly, you will see your logo, then an animation and a transition to the main screen.

What to do if the splash screen is not displayed?

Check whether the theme is specified correctly in Manifest. Make sure that the onCreate method does not call setContentView with a different layout before setting the desired one. Also check the logs (Logcat) for errors when loading resources.

How to make a splash screen for different screen orientations?

Create alternative layouts in the layout-land (for landscape) and layout-port (for portrait) folders. The Android system will automatically select the desired file depending on the position of the device.

Does SplashActivity need to be removed from the stack?

Yes, calling finish is required. If this is not done, the user will be able to return to the splash screen with the "Back" button, which is a gross error in the navigation logic.

Is it possible to use GIF on the splash screen?

Technically it is possible, but not recommended through ImageView. It's better to use AnimationDrawable or libraries like Glide/Fresco for GIF rendering to avoid performance and memory issues.

๐Ÿ“Š Which screensaver style do you like best?
Minimalism (logo only): Bright animation: Video background: Static poster

Creating a high-quality screensaver is a balance between aesthetics and performance. By following these recommendations, you will ensure a professional start for your application, which will have a positive impact on user perception of the brand.