How to make Splash Screen in your android project.
Steps
Create new project to give application name as SplashScreen
Keeping minimum SDK
Add on Activity and then finish to open new project.
Then add to EmptyActivity activity in your project.
Select EmptyActivity and give name SplashScreen
For display image copy to drawable folder.
Add to image view in activity_splash.xml file
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.root.splashscreen.SplashActivity"> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/logo" /> </RelativeLayout>
Then change theme to select NoTitlebar.
Then go to our main job as three minutes display splash screen.
Open SplashActivity.java to add this codes
package com.example.root.splashscreen; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); Thread myThread = new Thread(){ @Override public void run() { try { sleep(3000); Intent intent = new Intent(getApplicationContext(),MainActivity.class); startActivity(intent); finish(); } catch (InterruptedException e) { e.printStackTrace(); } } }; myThread.start(); } }
Then set Splash Screen to start activity.
Go to open manifest file
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.root.splashscreen"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".SplashActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"></activity> </application> </manifest>
Code that hides title bar of activity
- requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title
- getSupportActionBar().hide(); //hide the title bar
The setFlags() method of Window class is used to display content in full screen mode. You need to pass theWindowManager.LayoutParams.FLAG_FULLSCREEN constant in the setFlags method.