Open eunja511005 opened 7 months ago
res > layout 우클릭 > New > Layout Resource File > File Name 'loading_view.xml' 입력
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loadingAnimationView"
android:layout_width="100dp"
android:layout_height="100dp"
app:lottie_rawRes="@raw/loading_animation"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
[중요] 이름이 app:lottie_rawRes="@raw/loading_animation" 일치해야 인식 가능 하다.
1. 다이얼 로그 클래스를 만들고 해당 다이얼로그에서 Lottie의 애니메이션이 실행 되도록 한다.
2. 로딩 다이얼로그의 배경을 완전히 투명하게 만들어 줘야 애니메이션 실행 되는동안 보기 좋다.
// 로딩 다이얼로그 생성
LoadingDialog loadingDialog = new LoadingDialog(this);
// 로딩 다이얼로그 표시
loadingDialog.show();
// 로딩 다이얼로그 숨기기
loadingDialog.dismiss();
로티 라이브러리 의존성 추가 방법1
로티 라이브러리 의존성 추가 방법2