android 软键盘布局 及 关闭 弹出

来源:互联网 发布:高中课程教学视频软件 编辑:程序博客网 时间:2024/05/17 03:17

软键盘正常情况下 会挤压activity的 布局空间。。

在androidManifest 文件中 对相应的activity 设置

 android:windowSoftInputMode="adjustPan"    

这样软键盘就在activity contentView 上方。

 

 隐藏软键盘

 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(txt_name.getWindowToken(), 0);

 

 

t弹出软键盘

 

((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);