كيفية اضافة شاشة ترحبية للتطبيق SplashScreen على اندرويد استديو
طريقة انشاء شاشة ترحبية لتطبيقك على برنامج اندرويد استديو Splash Screen
اولا تقوم بتصميم الصورة والشكل الذى تريد ان تظهر علية الشاشة الترحبية وتعطى اسم للصورة باللغة الانجليزية وحروف صغيرة بدون ترك اى فراغات او مسافات ومن ثم نقل الصورة الى مجلد derawble وهو المجلد الخاص بتخزين الصور .
ثانيا تقوم بانشاء اكتفتى جديد وتسمية على سبيل المثال SplashScreenActivity
ثم تضع هذة الاكواد اولا داخل اكتفتى 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"tools:context=".SplashScreenActivity"><ImageViewandroid:id="@+id/pineLogo"android:layout_width="400dp"android:layout_height="500dp"android:src="@drawable/pinelogo"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>
ثانيا تذهب الى اكتفتى الكوتلن وهو الخاص بتنفيذ العملية البرمجية وتضع هذة الاكواد
والان تابع معى الشرح من خلال الفديو التالى لعدم الوقوع فى الاخطاء
import android.content.Intent
import androidx.appcompat.app.AppCompatActivityimport android.os.Bundleimport android.os.Handlerclass SplashScreenActivity : AppCompatActivity() {lateinit var handler: Handleroverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_splash_screen)handler = Handler()handler.postDelayed({// Delay and Start Activityval intent = Intent(this,MainActivity::class.java)startActivity(intent)finish()} , 3000) // here we're delaying to startActivity after 3seconds}}
لتحميل الكود سورس من هنااااااااا - اومن هناااااااااا - او من هناااااااااااااااااا