본문 바로가기

Kotlin/자주쓰는 내용 정리

나를 위한 Splash 화면

728x90

implementation 'com.airbnb.android:lottie:x.x.x'

github.com/airbnb/lottie-android

 

airbnb/lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native - airbnb/lottie-android

github.com

 

 

 

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 

lottiefiles.com/

 

photo on Lottiefiles. Free Lottie Animation

photos of acquaintances. Use on your web, react, flutter, xamarin iOS and Android projects and apps

lottiefiles.com