为EditText设置OnToucherListener,在执行onTouch之前先将EditText的InputType设置为TYPE_NULL,这是软键盘将不再弹出,光标也将失效。
onTouch执行过后,再将EditText的InputType恢复,光标也随之正常。
int inputType = et_input.getInputType(); et_input.setInputType(InputType.TYPE_NULL); et_input.onTouchEvent(event); et_input.setInputType(inputType); return true; 设置输入软键盘样式:android:windowSoftInputMode="adjustPan|stateHidden"影藏或者显示软键盘:
InputMethodManager imm = Context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(WindowToken token,InputManager.HIDE_NOT_ALWAYS);