fun hideInputManager(context: Context, view: View?) {
val imm: InputMethodManager =
context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
if (view != null && imm != null) {
imm.hideSoftInputFromWindow(view.windowToken, 0) //强制隐藏
}
}
fun hideSoftInput(view: View?) {
if (view == null) return
val inputMethodManager =
view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager?.hideSoftInputFromWindow(view.windowToken, 0)
}
(https://www.jianshu.com/p/91b7c3abface)