美文网首页
判断软键盘状态

判断软键盘状态

作者: 43d60efa37c7 | 来源:发表于2016-12-20 14:34 被阅读35次

//如果软键盘打开

if(getWindow().getAttributes().softInputMode==WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED){

     //隐藏

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

}

另外

public static void setHideInputMethod(Activity context) {

try {

InputMethodManager inputMethodManager = (InputMethodManager) context

.getApplicationContext().getSystemService(

Context.INPUT_METHOD_SERVICE);

inputMethodManager.hideSoftInputFromWindow(context

.getCurrentFocus().getWindowToken(),

InputMethodManager.HIDE_NOT_ALWAYS);

} catch (Exception e) {

}

}

相关文章

网友评论

      本文标题:判断软键盘状态

      本文链接:https://www.haomeiwen.com/subject/kiaxvttx.html