Created
September 6, 2023 09:52
-
-
Save amoozeshbebin/da1a34b4655005723f47c5b4fa1e3a26 to your computer and use it in GitHub Desktop.
Splash Screen Kotlin/Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActivityMain.kt: | |
package com.example.splashscreen | |
import android.content.Intent | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.os.Handler | |
import android.os.Looper | |
import android.widget.Button | |
class MainActivity : AppCompatActivity() { | |
private val wait: Long = 1000 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
Handler(Looper.getMainLooper()).postDelayed({ | |
val intent = Intent(this,MainActivity2::class.java) | |
startActivity(intent) | |
finish() | |
},wait) | |
} | |
} | |
____________________________________________________________ | |
ActivityMain.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/cardview_dark_background" | |
tools:context=".MainActivity"> | |
<ImageView | |
android:id="@+id/imageView" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="177dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:srcCompat="@drawable/ic_launcher_foreground" /> | |
<ProgressBar | |
android:id="@+id/progressBar" | |
style="?android:attr/progressBarStyle" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="28dp" | |
android:layout_marginTop="56dp" | |
app:layout_constraintStart_toStartOf="@+id/imageView" | |
app:layout_constraintTop_toBottomOf="@+id/imageView" /> | |
</androidx.constraintlayout.widget.ConstraintLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment