{"id":10080,"date":"2023-06-28T20:51:59","date_gmt":"2023-06-28T17:21:59","guid":{"rendered":"http:\/\/milmit.net\/how-to-make-splash-in-kotlin\/"},"modified":"2023-06-28T20:51:59","modified_gmt":"2023-06-28T17:21:59","slug":"how-to-make-splash-in-kotlin","status":"publish","type":"post","link":"https:\/\/milmit.net\/en\/how-to-make-splash-in-kotlin\/","title":{"rendered":"How to make Splash in Kotlin"},"content":{"rendered":"<p>We teach how to make Splash in Kotlin. Splash also has other names, such as the login page of the program or the start page of the program. In fact, SplashScreen is a page that displays information about the application, such as the name and logo, to the user at the beginning of the software, and more. It is used for branding in mobile applications. Stay with us to learn how to make a basic splash.<\/p>\n<p>What elements should be included in the splash page? The problem is this!<\/p>\n<ul>\n<li>Logo<\/li>\n<li>Progress bar<\/li>\n<li>Version code<\/li>\n<li>Brand name<\/li>\n<li>Animated logo<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>You must display either the Logo or an animation of the Logo in the middle of the screen. Placing the rest of the components is optional and there is no need to place all of them. If you receive data from the server side, be sure to display the Progressbar.<br \/>\nFor example, the Instagram application has a splash page like the one below.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-63891\" src=\"https:\/\/www.programchi.ir\/\/wp-content\/uploads\/2020\/07\/photo_2020-07-12_01-19-13.jpg\" sizes=\"auto, (max-width: 284px) 100vw, 284px\" srcset=\"https:\/\/programchi.ir\/wp-content\/uploads\/2020\/07\/photo_2020-07-12_01-19-13.jpg 623w, https:\/\/programchi.ir\/wp-content\/uploads\/2020\/07\/photo_2020-07-12_01-19-13-146x300.jpg 146w, https:\/\/programchi.ir\/wp-content\/uploads\/2020\/07\/photo_2020-07-12_01-19-13-498x1024.jpg 498w\" alt=\"\" width=\"284\" height=\"583\" \/><\/p>\n<p>Splash screen should not be used, but the user will understand what is happening and which application they are entering.<br \/>\nCreate an empty activity like below. (Be sure to create a raw project first called MainActivity, then continue with the steps below.)<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/miro.medium.com\/max\/2399\/1*MGJ0yJ-u95W5DoKN9Qwg-w.png\" alt=\"Image for post\" width=\"1029\" height=\"548\" \/><br \/>\nAnd name it as below SplashActivity.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/miro.medium.com\/max\/1495\/1*YxKsyliTy-RUexgMR3ndpA.png\" alt=\"Image for post\" width=\"1052\" height=\"796\" \/><\/p>\n<p>Wait for a while to sync.<br \/>\nentered the following path<br \/>\napp\u2192res\u2192values\u2192colors.xml<br \/>\nand put the following codes.<\/p>\n<div id=\"crayon-6140897f684ab799307098\" class=\"crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate\" data-settings=\" touchscreen minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\"\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;!-- All the colors used in the application --&gt;\r\n&lt;resources&gt;\r\n    &lt;color name=\"colorPrimary\"&gt;#008577&lt;\/color&gt;\r\n    &lt;color name=\"colorPrimaryDark\"&gt;#00574B&lt;\/color&gt;\r\n    &lt;color name=\"colorAccent\"&gt;#D81B60&lt;\/color&gt;\r\n    &lt;color name=\"grey\"&gt;#d3d3d3&lt;\/color&gt;\r\n    &lt;color name=\"white\"&gt;#ffffff&lt;\/color&gt;\r\n    &lt;color name=\"black\"&gt;#000000&lt;\/color&gt;\r\n&lt;\/resources&gt;<\/pre>\n<p>Enter the activity_splash.xml section and change its codes as below.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\r\n    android:orientation=\"vertical\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:background=\"@color\/grey\"&gt;\r\n    &lt;ImageView\r\n        android:id=\"@+id\/imageView\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_marginTop=\"250dp\"\r\n        android:src=\"@drawable\/ic_launcher_background\"\r\n        app:srcCompat=\"@android:drawable\/sym_def_app_icon\" \/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/textView\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"Name of the Application\"\r\n        android:textSize=\"20dp\"\r\n        android:textStyle=\"bold\"\r\n        android:gravity=\"center\"\r\n        android:textColor=\"@color\/black\"\r\n        android:layout_below=\"@id\/imageView\"\r\n        android:padding=\"30dp\"\/&gt;\r\n    &lt;ProgressBar\r\n        android:id=\"@+id\/progressBar\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@id\/textView\"\r\n        android:layout_centerHorizontal=\"true\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:indeterminateTint=\"@color\/black\"\/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/textView1\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@id\/progressBar\"\r\n        android:gravity=\"center\"\r\n        android:layout_marginTop=\"200dp\"\r\n        android:padding=\"15dp\"\r\n        android:text=\"Designed by Your Name Here\"\r\n        android:textColor=\"@color\/black\"\r\n        android:textSize=\"15dp\"\r\n        android:textStyle=\"bold\"\r\n        android:textAlignment=\"center\"\/&gt;\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>Now it&#8217;s time to remove the actionbar related to your home screen, for this, enter the following path<br \/>\napp \u2192 res \u2192 values \u2192 styles.xml<br \/>\nand define the following style.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;style name=\"AppTheme.NoActionBar\"&gt;\r\n        &lt;item name=\"windowActionBar\"&gt;false&lt;\/item&gt;\r\n        &lt;item name=\"windowNoTitle\"&gt;true&lt;\/item&gt;\r\n    &lt;\/style&gt;<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import android.content.Intent\r\nimport androidx.appcompat.app.AppCompatActivity\r\nimport android.os.Bundle\r\nimport android.os.Handler\r\nclass SplashActivity : AppCompatActivity() {\r\n    \/\/ This is the loading time of the splash screen\r\n    private val SPLASH_TIME_OUT:Long = 3000 \/\/ 3 sec\r\n    override fun onCreate(savedInstanceState: Bundle?) {\r\n        super.onCreate(savedInstanceState)\r\n        setContentView(R.layout.activity_splash)\r\n        Handler().postDelayed({\r\n            startActivity(Intent(this,MainActivity::class.java))\r\n            \/\/ close this activity\r\n            finish()\r\n        }, SPLASH_TIME_OUT)\r\n    }\r\n}<\/pre>\n<p>What happened above is that a 3-second time delay was created by using the postdelay method of the handler. Pay attention, you must set the time based on milliseconds, that is, every 1000 seconds will be equal to 1 second. Above, delay is equal to 3 definitions. and finally, after 3 seconds, it takes us to the main activity.<br \/>\nNow enter AndroidManifest.xml. Find MainActivity and cut the following lines<\/p>\n<div id=\"crayon-6140897f684c2239746760\" class=\"crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate\" data-settings=\" touchscreen minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\"\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;intent-filter&gt;\r\n        &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n        &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n    &lt;\/intent-filter&gt;<\/pre>\n<p>And finally set it to SplashActivity like below<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;activity android:name=\".SplashActivity\"\r\n    android:theme=\"@style\/AppTheme.NoActionBar\"&gt;\r\n    &lt;intent-filter&gt;\r\n        &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n        &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n    &lt;\/intent-filter&gt;\r\n&lt;\/activity&gt;<\/pre>\n<p>and over<\/p>\n<p>be successful and victorious.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We teach how to make Splash in Kotlin. Splash also has other names, such as the login page of the program or the start page of the program. In fact, SplashScreen is a page that displays information about the application, such as the name and logo, to the user at the beginning of the software, [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":4916,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-10080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts\/10080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/comments?post=10080"}],"version-history":[{"count":0,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/posts\/10080\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/media\/4916"}],"wp:attachment":[{"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/media?parent=10080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/categories?post=10080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/milmit.net\/en\/wp-json\/wp\/v2\/tags?post=10080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}