Splash Screen code

 activity_splash_screen.xml :

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/teal_700"
tools:context=".SplashScreen">

<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="196dp"
android:src="@mipmap/ic_launcher_round"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-smallcaps"
android:gravity="center_vertical"
android:layout_marginTop="20dp"
android:paddingBottom="5dp"
android:text="Wp Status Downloader"
android:textColor="@android:color/white"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />


</androidx.constraintlayout.widget.ConstraintLayout>


SplashScreen.class :

public class SplashScreen extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Thread thread = new Thread(){
@Override
public void run(){
try {
sleep(500);

Intent intent= new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
finish();
}
catch (Exception e){
e.printStackTrace();
}
}
};thread.start();

}
}








Post a Comment

0Comments
Post a Comment (0)