/***
* 获取导航栏的高度
* @return
*/
private int getNavigatorBarHeight() {
int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
int height = getResources().getDimensionPixelSize(resourceId);
return height;
}
/****
* @return true为显示软键盘 false为显示软键盘
*/
private boolean isShowKeyboard(){
int screenHeight = getWindow().getDecorView().getHeight();
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
return !(screenHeight <= (rect.bottom+getNavigatorBarHeight()));
}
/***
* 隐藏软件
*/
private void hideKeyboard(){
InputMethodManager inputMethodManager = ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE));
inputMethodManager.hideSoftInputFromWindow(ContactsActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
以上代码在LG、三星、Vovi、华为手机上一验证,欢迎纠正