Splash Screen: Add Splash Screen in Android Studio - RRutors
Android splashscreen, add splash screen to app with kotlin | RRTutors: Guide on adding a splash screen to your Android app using Kotlin. Check it out today!
In this article, we will see how to create a Splash Screen in Android Studio using Kotlin Language.
What is Splash Screen?
A splash screen is a graphical control element that consists of a window with an image, a logo, or any widget. While a game or any app is being launched, a splash screen may appear. A splash screen is a screen that contains the introduction an app or website.
Implementation:
Create a new Project in android studio.
|
Go to File > New > New Project > Empty Activity > Next > Enter Name > Select Language Kotlin > Finish |
Go to activity_splash.xml file and add the following code
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ImageView </LinearLayout> |
Open SplashActivity.kt file and hide the action bar or status bar line by adding the following code
|
window.setFlags( |
this code will help you to make the splash activity fullscreen.
Add Handler method to the SplashActivity.kt file for persist the screen for particular time (Add below setContentView(R.layout.activity_splash)).
|
Handler().postDelayed({ |
Create a new empty activity name HomeActivity,kt file
|
app > java > package name > right-click > New > Activity /Empty Activity > enter name(HomeActivity.kt) > Finish. |
Open activity_home.xml file and add following code.
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <TextView </LinearLayout>
|
Now run the code in your emulator or device, you will get the following output.
Complete Source code of Splash Screen Example:
activity_splash.xml file
|
<?xml version="1.0" encoding="utf-8"?> <ImageView </LinearLayout> |
SplashActivity.kt file
|
import android.content.Intent class SplashActivity : AppCompatActivity() { |
activity_home.xml file
|
<?xml version="1.0" encoding="utf-8"?> <TextView </LinearLayout> |
Conclusion: We have covered how to design and implement splash screen in Android using kotlin language.