private var dialog: Dialog? = null
val linearLayout = LinearLayout(context)
linearLayout.gravity = Gravity.CENTER
linearLayout.setBackgroundColor(Color.TRANSPARENT)
val progressBar = ProgressBar(context)
linearLayout.addView(
progressBar,
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
)
dialog = Dialog(context)
dialog?.requestWindowFeature(Window.FEATURE_NO_TITLE)
if (dialog?.window != null) {
dialog?.window?.setBackgroundDrawableResource(android.R.color.transparent)
}
dialog?.setContentView(
linearLayout,
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
dialog?.setCancelable(false)
dialog?.setOnKeyListener { dialog, keyCode, event -> keyCode == KeyEvent.KEYCODE_SEARCH && event.repeatCount == 0 }
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) // Dialog 뒷 배경 검정색으로 나오지않게하기
dialog?.show()
'프로그래밍 > Kotlin' 카테고리의 다른 글
[Kotlin] Java -> Kotlin Converting후 CustomDialog를 열때 Nullpointer Exception (0) | 2022.12.05 |
---|---|
[Kotlin] 가변인자를 변수로 넘기기 (변수명앞에 별표[*]) (0) | 2022.11.10 |
[Android] 클릭리스너를 변수로 등록하여 사용하는법 (0) | 2022.08.31 |
[kotlin] BottomNavigationView (0) | 2022.08.10 |
[Kotlin] TabLayout (0) | 2022.08.09 |
댓글