Home 5월 22일 Today I Learned
Post
Cancel

5월 22일 Today I Learned

오늘한 일

  • 프로젝트를 진행하였다
  • 블로그 TIL을 작성하였다
  • 1일 1커밋을 하였다

느낌 점

내가 너무 프로젝트를 마치는데 조급해하고 있다는 것을 알게 되었다 물론 프로젝트에 기간도 중요하니 빨리 끝내면 좋지만 현재 나는 원래 존재하던 앱을 좀 더 발전시켜서 더 좋은 앱을 만들려하고 있고 그 와중에도 조금씩 디자인이나 로직을 수정하고 있는데 하지만 이렇게 하지 않고 그냥 계속 타협하면서 했다면 기간은 줄일 수 있겠지만 남에게 또 당당히 보여주기에는 부끄러울 거 같기에 아직도 한달도 되지 않은 이 시점에서 조급함을 조금 내려놓고 앱을 좋은 퀄리티로 만드는 것만 집중해야겠다

배운 점

Android 아름다운 Loading Dialog 만들기

안드로이드 앱을 개발하다보면 사용자에게 앱이 멈춘 것이 아닌 데이터를 로드하고 있는 중이라는 것을 보여줄 필요가 있다 그럴 때 Loading Dialog를 보여줘야 하는데 로티파일을 사용하면 아름다운 Loading Dialog를 만들 수 있다 해당 방법에 대한 예시 코드를 보여주면

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class LoadingDialog(private val context: Context) {
    private val dialog: Dialog = Dialog(context)

    init {
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
        dialog.setCancelable(false)
        dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialog.setContentView(R.layout.loding_dialog)

        val animationView = dialog.findViewById<LottieAnimationView>(R.id.animation_view)
        animationView.setAnimation("loading.json")
        animationView.loop(true)
        animationView.playAnimation()
    }

    fun show() {
        dialog.show()
    }

    fun dismiss() {
        dialog.dismiss()
    }
}

이러한 클래스를 만들어주고 layout 파일로는

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animation_view"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:layout_margin="16dp"
        app:lottie_autoPlay="true"
        app:lottie_loop="true"
        app:lottie_fileName="loading.json" />

    <TextView
        android:layout_marginTop="60dp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Loading..."
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:textSize="26sp" />

</FrameLayout>

이런식으로 제작하면 되며 사용하는 곳에서는

1
2
3
4
val loadingDialog = LoadingDialog(requireContext())

loadingDialog.show()
loadingDialog.dismiss()

이렇게 사용할 수 있다

내일 계획

내일은 코딩 보카 프로젝트를 진행해야겠다

This post is licensed under CC BY 4.0 by the author.

5월 21일 Today I Learned

5월 23일 Today I Learned