Last active
May 26, 2022 07:06
-
-
Save senamit2708/e9a4c4dc9663333e5c17fb5294ab43ed to your computer and use it in GitHub Desktop.
splash screen
This file contains hidden or 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
| for extra detail about splash screen follow this article. | |
| https://medium.com/geekculture/implementing-the-perfect-splash-screen-in-android-295de045a8dc |
This file contains hidden or 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
| now create one activity for splash screen and then in the mainfest change that splash screen activity as launcher. | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="ecaps.dna.sharinghabit"> | |
| <application | |
| android:allowBackup="true" | |
| android:icon="@mipmap/ic_launcher" | |
| android:label="@string/app_name" | |
| android:roundIcon="@mipmap/ic_launcher_round" | |
| android:supportsRtl="true" | |
| android:theme="@style/Theme.SharingHabit"> | |
| <activity | |
| android:name=".SplashActivity" | |
| android:theme="@style/SplashTheme" | |
| android:exported="true"> | |
| <intent-filter> | |
| <action android:name="android.intent.action.MAIN" /> | |
| <category android:name="android.intent.category.LAUNCHER" /> | |
| </intent-filter> | |
| </activity> | |
| <activity | |
| android:name=".MainActivity" | |
| android:exported="true"> | |
| <intent-filter> | |
| <action android:name="android.intent.action.MAIN" /> | |
| <category android:name="android.intent.category.DEFAULT" /> | |
| </intent-filter> | |
| </activity> | |
| </application> | |
| </manifest> |
This file contains hidden or 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
| import android.content.Intent | |
| import android.os.Bundle | |
| import android.os.Handler | |
| import android.os.Looper | |
| import androidx.appcompat.app.AppCompatActivity | |
| class SplashActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_splash) | |
| val intent = Intent(this@SplashActivity, MainActivity::class.java) | |
| startActivity(intent) | |
| /* Handler(Looper.getMainLooper()).postDelayed(object : Runnable{ | |
| override fun run() { | |
| val intent = Intent(this@SplashActivity, MainActivity::class.java) | |
| startActivity(intent) | |
| } | |
| }, 1000) | |
| */ | |
| } | |
| } |
This file contains hidden or 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
| if you are using image for splash screen, save that image to the drawable folder example:- splashscreen_one.png | |
| then in the style.xml page | |
| <style name="SplashTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> | |
| <item name="android:windowBackground">@drawable/splashscreen_one</item> | |
| </style> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment