기본 progressBar의 뒷 배경에 blur 처리를 위해 AlertDialog를 사용.
progressBar를 module화 함으로 여러 곳에서 다양하게 사용하기 위해 만듬.
// progress 시작 시 val progressBar = customProgressBar(context, layoutinflater
// 종료 시 progressBar.dismiss()
fun customProgressBar(context: Context, layoutInflater: LayoutInflater): AlertDialog { | |
val binding = DialogProgressbarBinding.inflate(layoutInflater) | |
return AlertDialog.Builder(context) | |
.setCancelable(false) | |
.setView(binding.root) | |
.show().apply { | |
// 뒷 배경 blur 처리 | |
this.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | |
} | |
} |
<?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" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
> | |
<ProgressBar | |
android:id="@+id/progress_bar" | |
android:visibility="visible" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:layout_constraintVertical_bias="0.4" | |
app:layout_constraintLeft_toLeftOf="parent" | |
app:layout_constraintRight_toRightOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent" | |
/> | |
</androidx.constraintlayout.widget.ConstraintLayout> |