Android R부터는 SOFT_INPUT_ADJUST_RESIZE 가 Deprecated 되었습니다.
그 대안으로 사용되는 코드입니다.
setDecorFitsSystemWindows(false) 으로 설정하고, setOnApplyWindowInsetsListener 안에서 WindowInsets으로 여러가지 시스템 컴포넌트의 Inset을 받아와 rootView에 Padding을 적용합니다.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
dialog?.window?.setDecorFitsSystemWindows(false)
viewDataBinding.root.setOnApplyWindowInsetsListener { _, insets ->
val topInset = insets.getInsets(WindowInsets.Type.statusBars()).top
val imeHeight = insets.getInsets(WindowInsets.Type.ime()).bottom
val navigationHeight = insets.getInsets(WindowInsets.Type.navigationBars()).bottom
val bottomInset = if (imeHeight == 0) navigationHeight else imeHeight
viewDataBinding.root.setPadding(0, topInset, 0, bottomInset)
insets
}
} else {
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}