Thu. Oct 3rd, 2024

Creating a splash screen in an Android app involves designing a screen that is displayed briefly when the app is launched, providing a visual transition before the main content appears. Here’s a step-by-step guide on how to create a simple splash screen in an Android app:

  1. Create Layout File: First, create a layout XML file for your splash screen. This file will define the UI elements displayed on the splash screen. Create a new XML file in your res/layout directory (e.g., activity_splash.xml):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Splash">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"></ImageView>


</RelativeLayout>

Splash.kt

package com.androindian.harikaproject

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler

class Splash : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)

        Handler().postDelayed(Runnable {
            var intent=Intent(this,MainActivity::class.java)
            startActivity(intent)
        },5000)
    }
}

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *