public static void hideSoftInputView(Activity activity) {
InputMethodManager manager = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if(activity.getWindow().getAttributes().softInputMode != 2 && activity.getCurrentFocus() != null) {
manager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 2);
}
}
android点击界面隐藏键盘
来源:华佗小知识