How to Create Splash screen in Android studio

we lean How to Create Splash screen in Android studio. follow these steps its help you.






Step 1:-  Create an activity if you don't know how to Create An please check my Previous Post .it helps You.


Step 2:- open .xml file write code which like you want (logo and tag line of your app) 

For example :- check below 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"
tools:context=".Activity2">


<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
android:src="@drawable/techwithion" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="6dp"
android:text="TECH WITH ION"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:textSize="25sp"
android:textColor="@color/black"
android:textStyle="bold"/>

</RelativeLayout>



Step 2:- Write code on java file


package com.ehowsongs.newapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

public class Activity2 extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_2);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

new Handler().postDelayed(new Runnable() {
@Override
public void run() {

Intent intent = new Intent(Activity2.this, MainActivity.class);
startActivity(intent);
finish();

}
},2000);

}
Step 3:- change in Manifest file :-
Mainactivity to Splash screen Activity check below photos for understanding:-







Change in Manifest file:-




Step 4:- Change Theme files like this

<style name="Theme.Newapp" parent="Theme.MaterialComponents.DayNight.NoActionBar">

Output :-






Post a Comment

Previous Post Next Post