로띠란 에어비엔비에서 만든 오픈 소스 모바일 라이브러리이다. 픽셀 단위가 아닌 벡터 기반이라서 애니메이션에 특화되어 여러 장점을 가지고 있다. 로띠를 사용하면 사용자와 보다 효과적인 상호작용이 될 것이다.
dependencies {
implementation 'com.airbnb.android:lottie:$lottieVersion'
}
다운받은 로띠 json 파일을 res/raw 파일 위치에 놓는다.
airbnb의 lottie view 를 사용해서 다운받은 json파일을 등록한다.
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/view_lottie"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:lottie_autoPlay="true"
app:lottie_rawRes="@raw/splash" />
💡 lottie_autoPlay : 별다른 시작없이 바로 시작하도록 하는 설정 !
액티비티에서 리스너를 등록할 수 있다.
start, end, cancel, repeat
binding.viewLottie.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationStart(p0: Animator?) {}
override fun onAnimationEnd(p0: Animator?) {}
override fun onAnimationCancel(p0: Animator?) {}
override fun onAnimationRepeat(p0: Animator?) {}
})