问题:页面上滑键盘不隐藏
解决方案:
在布局文件中添加
android:focusable="true"
android:focusableInTouchMode="true"
在对应的Activity中重写dispatchTouchEvent
//重写dispatchTouchEvent 向上滑动隐藏键盘
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (getCurrentFocus() != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
return super.dispatchTouchEvent(ev);
}