고기를 불판 위에 닿을때, Smoke (연기 효과를 주고 싶었다)
Android Studio에서 Lottie 사용하는 방법!
Getting Started with Lottie Animations in an Android App - LottieFiles
A step-by-step on how to get started with Lottie animations in an Android app.
lottiefiles.com
1. 마음에 드는 Lottie 애니메이션을 고른다
2. Android Studio build.gradle 파일에 가서 dependencies추가하기
/app/밑에 New->Folder->assets파일을 추가한다
추가하고자 하는 애니메이션을 json으로 다운받는다
Smoke - steam on Lottiefiles. Free Lottie Animation
simple shape layer recreating smoke. Use on your web, react, flutter, xamarin iOS and Android projects and apps
lottiefiles.com
json파일을 assets파일에 넣는다!
assets파일에 넣으면, 오류가 나길래, 직접 이 폴더파일에 넣어주었다.
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/smoke_animation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="78594-smoke-steam.json"
app:lottie_autoPlay="true"
app:lottie_loop="true"/>
내가 원하는 Layout 파일에 LottieAnimationView를 추가한다
filename에는 아까 넣어준 json파일을 넣어준다.
autoplay는 시작하자마자 재생할 것인지
loop는 반복할것인지에 대한 내용!
잘 실행되는 것을 알 수 있다!
위치조정이랑 크기조정을 해야할 것 같다!
binding.animationView.setOnClickListener {
binding.animationView.playAnimation()
}
이런식으로 메소드를 이용해 원할때 재생시킬수도 있다!
'기타 > Android' 카테고리의 다른 글
[Android Studio / Kotlin] 안드로이드 효과음 넣기 (soundPool) / 고기굽는 소리 (0) | 2022.02.28 |
---|---|
[Kotlin] 코틀린 HashMap value 기준으로 정렬하기 (0) | 2022.02.28 |
[ Android / Kotlin ] 안드로이드 액티비티 전환 애니메이션 (0) | 2022.02.26 |
[Android] 상태바, 타이틀바 없애기 (0) | 2022.02.20 |
[Android] shape 속성 (0) | 2022.02.19 |