【发布时间】:2015-07-29 16:39:56
【问题描述】:
我不询问如何防止键盘在屏幕弹出时向上推。
当我单击EditText 时,键盘出现,屏幕保持不变。但问题是当我在EditText 之外单击时,键盘隐藏然后(大约半秒后)屏幕跳动一点(在底部),然后重新安定下来。
我正在使用自定义键盘和自定义 EditText。
在我设置的活动中:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
当EditText 获得焦点时,这就是我显示键盘的方式:
InputMethodManager inputMethodManager = (InputMethodManager)MainApplication.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput( view, 0 );
当EditText失去焦点时隐藏它:
InputMethodManager inputMethodManager = (InputMethodManager)MainApplication.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
编辑:
并不是说当我在键盘上按 DONE 时,键盘只是隐藏(没有屏幕跳跃),但 EditText 不会失去焦点。因此,如果可以在 EditText 即将失去焦点时模拟 DONE 按下,这对我来说没问题。
【问题讨论】: