सीधे मुख्य सामग्री पर जाएं

Splash screen in Android Studio source code | Splash screen android code ||

 Splash screen in Android Studio source code | Splash screen android code !

A splash screen is a graphical control element consisting of a window containing an image, a logo, and the current version of the software. A splash screen can appear while a game or program is launching. A splash page is an introduction page on a website. A splash screen may cover the entire screen or web page; or may simply be a rectangle near the center of the screen or page. The splash screens of operating systems and some applications that expect to be run in full screen usually cover the entire screen.



Add the color in the colors.xml file as given:

<color name="my_colour">#0E3746</color>


Splash Activity Java Code:

package com.example.splashactivityclass;

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

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashActivity.this,MainActivity.class));
            }
        },2000);

    }
}

Splash Activity Xml Code:

<?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"
    android:background="@color/my_colour"
    tools:context=".SplashActivity">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hr_group"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:textColor="@color/white"
        android:textSize="35sp"
        android:textStyle="bold"
        />
    <ProgressBar
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_below="@id/name"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        />
</RelativeLayout>

Output:









टिप्पणियाँ