반응형
New Activity 생성하기
manifests 들어가기
intent-filter를 SplashActivity 사이에 껴넣어준다
(여기서 activity 부분에 true 란에 공백이 있는지 한 번더 확인한다. 공백이 있으면
the element type "application" must be terminated by the matching end-tag "</application>".
이 오류가 뜬다.)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Splash"
tools:targetApi="31">
<activity
android:name=".SplashActivity"
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"></activity>
</application>
</manifest>
Splash Activity layout에 Image View 생성
<?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=".SplashActivity">
<ImageView
android:src="@drawable/love"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Splash Activity에 어플 실행 시 첫 화면 딜레이 시간 설정 (Handler)
package com.example.splash
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
Handler().postDelayed({
startActivity(Intent(this, MainActivity::class.java))
finish() },3000)
}
}
정상실행 완료
반응형
'kotlin↗ > 안드로이드 스튜디오 메이킹' 카테고리의 다른 글
KOTLIN]해당 이미지(버튼)을 누르면 원하는 화면으로 넘어가기 (0) | 2024.02.01 |
---|---|
KOTLIN]이미지 일정하게 간격 두면서 테두리 둥글게 만들기 (0) | 2024.02.01 |
KOTLIN]ListView A,B,C 누르는 기본적인 항목 만들기 (1) | 2024.02.01 |
KOTLIN]앱 배경화면 이미지로 변경하기 (0) | 2024.02.01 |
KOTLIN] ListView 작성하기 (0) | 2024.02.01 |