Спасибо, @Gal Machluf Я попробовал ваш метод, но после показа программной клавиатуры нижняя кнопка исчезает. Что мне делать?
[KeyboardVisibilityUtils.kt]
private val onGlobalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
window.decorView.getWindowVisibleDisplayFrame(windowVisibleDisplayFrame)
val visibleDecorViewHeight = windowVisibleDisplayFrame.height()
Log.d("debugTest", "visibleDecorViewHeight : $visibleDecorViewHeight")
if (lastVisibleDecorViewHeight != 0) {
if (lastVisibleDecorViewHeight > visibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX) {
val currentKeyboardHeight = window.decorView.height - windowVisibleDisplayFrame.bottom
Log.d("debugTest","decorView height : ${window.decorView.height}, 현재보여지고 있는 크기의 가장 아래 : ${windowVisibleDisplayFrame.bottom}")
onShowKeyboard?.invoke(currentKeyboardHeight)
} else if (lastVisibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX < visibleDecorViewHeight) {
onHideKeyboard?.invoke()
}
}
lastVisibleDecorViewHeight = visibleDecorViewHeight
}
[SignUpFragment.kt]
//키보드 가시성 유틸 초기화
keyboardVisibilityUtils =
KeyboardVisibilityUtils(activity!!.window,
onShowKeyboard = {
keyboardListener?.onShowKeyboard()
},
onHideKeyboard = {
keyboardListener?.onHideKeyboard()
}
)
[SignUpActivity.kt]
override fun onShowKeyboard() {
Log.d("debugTest", "하단버튼을 없앤다.")
viewDataBinding.run {
btnNextSignUp.visibility = View.GONE
viewFooterSignUp.visibility = View.GONE
}
}
override fun onHideKeyboard() {
Log.d("debugTest", "하단버튼을 생성한다.")
viewDataBinding.run {
btnNextSignUp.postDelayed({
btnNextSignUp.visibility = View.VISIBLE
viewFooterSignUp.visibility = View.VISIBLE
}, 50)
}
}