android 显示和隐藏输入法框

显示输入法

val manager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
manager?.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)

隐藏输入法

val manager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
if (manager?.isActive == true) {
    manager.hideSoftInputFromWindow(
        v.windowToken,
         InputMethodManager.HIDE_NOT_ALWAYS
    )
}

 

posted @ 2020-08-20 16:01  荣超  阅读(739)  评论(0编辑  收藏  举报