findViewById(R.id.rootlayout).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(null !=MyFamilyCountActivity.this.getCurrentFocus()){
/**
* 点击空白位置 隐藏软键盘
*/
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
if (mInputMethodManager !=null) {
return mInputMethodManager.hideSoftInputFromWindow(MyFamilyCountActivity.this.getCurrentFocus().getWindowToken(), 0);
}
}
return false;
}
});
这里的rootlayout就是根布局的ID
网友评论