直接加上下面这个方法,搞定了
//触摸屏幕就关闭输入法
@Override
public boolean onTouchEvent(MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
// 显示或者隐藏输入法
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
return true;
}