0 works

How do I make a splash screen?


dashboard+ Project

Posted by @Awais malik #android #java

Step 0: First of all design layout of your splash screen an example is given below

<?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="@drawable/backgroundgradient"
    tools:context=".ui.Signup">

    <ImageView
            android:layout_width="130dp"
            android:layout_height="100dp"
            android:layout_centerInParent="true"
            android:src="@drawable/logosp" />

</RelativeLayout>
content_copyCopy to Clipboard

Step 1: here we make an activity named as SplashScreen in which we use handler class for delay when time expires next activity launches

public class SplashScreen extends AppCompatActivity {



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

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashScreen.this , MainActivity.class);
                startActivity(intent);
                finish();
            }
        } , 3000);
    }
}
content_copyCopy to Clipboard

In this tutorial i will teach you how to design a splash screen in android

,

>> Browse more code snippets

more_vert