728x90
implementation 'com.airbnb.android:lottie:x.x.x'
github.com/airbnb/lottie-android
SplashActivity.kt
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.Handler
class SplashActivity : Activity(){
val TIME_OUT : Long = 2000
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
Handler().postDelayed(Runnable {
kotlin.run {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}
}, TIME_OUT)
}
}
activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:background="@color/windowBackground"
android:layout_gravity="center">
<com.airbnb.lottie.LottieAnimationView
android:layout_margin="100dp"
android:id="@+id/animation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/splash" />
</LinearLayout>
/res/raw/splash.json
'Kotlin > 자주쓰는 내용 정리' 카테고리의 다른 글
안드로이드 Logger Util (0) | 2022.06.09 |
---|---|
Android Studio: CreateProcess error=206, The filename or extension is too long (0) | 2021.07.02 |
RecyclerView 클릭이벤트 인터페이스 (0) | 2021.01.15 |