当用户在两个 EditText 字段上输入时,我将页面的整个布局移动了 250,当键盘被关闭时,我需要将它拉回来,我使用
公共类 DoneOnEditorActionListener 实现 OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// TODO Auto-generated method stub
try{
if (actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_NULL
|| event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
LoginActivity.rootView.setY(0);
return true;
}
}catch (Exception e){
}
return false;
}
它工作正常,但是当我单击后退按钮时,键盘也被关闭并且布局不会向后移动。有没有办法仅在软键盘启动时禁用后退按钮?