how do i make a splash screen 3f

Solutions on MaxInterview for how do i make a splash screen 3f by the best coders in the world

showing results for - "how do i make a splash screen 3f"
Romina
24 Jan 2019
1//MainActivity.java
2
3import androidx.appcompat.app.AppCompatActivity;
4import android.os.Bundle;
5
6public class MainActivity extends AppCompatActivity {
7
8    @Override
9    protected void onCreate(Bundle savedInstanceState) {
10        super.onCreate(savedInstanceState);
11        setContentView(R.layout.activity_main);
12    }
13}
14
15//splashscreen.java
16
17import android.app.Activity;
18import android.content.Intent;
19import android.os.Bundle;
20import android.os.Handler;
21
22public class splashscreen extends Activity {
23    @Override
24    public void onCreate(Bundle savedInstanceState) {
25        super.onCreate(savedInstanceState);
26        setContentView(R.layout.splashscreen);
27
28        //Splash Screen duration
29        int secondsDelayed = 1;
30        new Handler().postDelayed(new Runnable() {
31            public void run() {
32                startActivity(new Intent(splashscreen.this, MainActivity.class));
33                finish();
34            }
35        }, secondsDelayed * 3000);
36    }
37}
38
39//activity_main.xml
40
41<?xml version="1.0" encoding="utf-8"?>
42<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
43    xmlns:app="http://schemas.android.com/apk/res-auto"
44    xmlns:tools="http://schemas.android.com/tools"
45    android:layout_width="match_parent"
46    android:layout_height="match_parent"
47    tools:context=".MainActivity">
48
49    <TextView
50        android:layout_width="wrap_content"
51        android:layout_height="wrap_content"
52        android:text="Hello World!"
53        app:layout_constraintBottom_toBottomOf="parent"
54        app:layout_constraintLeft_toLeftOf="parent"
55        app:layout_constraintRight_toRightOf="parent"
56        app:layout_constraintTop_toTopOf="parent" />
57
58</androidx.constraintlayout.widget.ConstraintLayout>
59
60//splashscreen.xml
61
62<?xml version="1.0" encoding="utf-8"?>
63<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
64    android:orientation="vertical" android:layout_width="match_parent"
65    android:layout_height="match_parent"
66    android:background="@drawable/splashlogo"
67
68    />
69      
70Source: https://github.com/Lunox-Code/SplashScreen
similar questions
splash screen android