思路根据高度判断是否在关闭键盘,返回键和键盘上关闭按钮有效 var keypadHeight = 0 binding.etInput.viewTreeObserver.addOnGlobalLayoutListener(OnGlobalLayoutListener { val r = Rect() binding.etInput.getWindowVisibleDisplayFrame(r) val screenHeight: Int = binding.etInput.rootView.height var height = screenHeight - r.bottom keypadHeight = max(keypadHeight,height) if (height<keypadHeight){ dismiss() } })
04-14
581