在含有EditText的界面软键盘一般会自动弹出,这样会影响界面的显示效果,需要我们把软键盘关闭,方法如下:
方法一:
在AndroidMainfest.xml中选择那个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
<activity
... android:windowSoftInputMode="adjustUnspecified|stateHidden"
</activity>
方法二:
让EditText失去焦点,使用EditText的clearFocus方法
方法三:
强制隐藏Android输入法窗口
EditText edit=(EditText)findViewById(R.id.edit)
imm.hideSoftInputFromWindow(edit.getWindowToken(),0)
或者
View view = getWindow().peekDecorView()
if (view != null) {
InputMethodManager im = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE)
im.hideSoftInputFromWindow(view.getWindowToken(),0)
}
方法四:
EditText始终不弹出软件键盘
EditText edit=(EditText)findViewById(R.id.edit)
edit.setInputType(InputType.TYPE_NULL)