728x90
1. build.gradle에 Lottie 를 추가합니다.
// 로티
implementation 'com.airbnb.android:lottie:3.7.0'
2. asset folder를 생성합니다.
> 사용할 Lottie Anmation 찾기 : https://lottiefiles.com/search?q=space&category=animations
Free Lottie Animation Files, Tools & Plugins - LottieFiles
The world’s largest online platform for the world’s smallest animation format for designers, developers, and more. Access Lottie animation tools and plugins for Android, iOS, and Web.
lottiefiles.com
3. Lottie를 사용할 폴더 안에 적용해줍니다.
app:lottie_fileName="space.json" -> 여기에 asset 폴더에 있는 사용하실 파일명을 입력하시면 됩니다.
<?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=".MainActivity">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_fileName="space.json"
app:lottie_loop="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
간단하게 애니메이션이 보이는 것을 알 수 있습니다.
'안드로이드 코틀린' 카테고리의 다른 글
[Kotlin][Android] 터치 제스처 감지 (Gesture Detector) (0) | 2022.08.13 |
---|---|
[Kotlin][Android] 안드로이드 시간 표현하기 (2) | 2022.08.06 |
[Kotlin][Android] 안드로이드 연속 클릭 막기 (0) | 2022.07.22 |
[Kotlin][Android] 파일 쓰고 불러오기 (0) | 2022.07.13 |
[kotlin][Android] 안드로이드에서 긴 글 가져오기 (0) | 2022.07.07 |