/**
* 判断键盘是否显示
*
* @return true 显示
*/
public static boolean isSoftShowing(Activity activity) {
//获取当前屏幕内容的高度
int screenHeight = activity.getWindow().getDecorView().getHeight();
//获取View可见区域的bottom
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
return screenHeight - rect.bottom != 0;
}
/**
* 隐藏键盘
*/
public static void hide(Activity activity) {
if (isSoftShowing(activity)){
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}
隐藏键盘
/** * 判断键盘是否显示 * * @return true 显示 */public static boolean isSoftShowing(Activity activity) { //获取当前屏幕内容的高度 int screenHeight = activity.getWindow().getDe...
- 发表于 2019-04-03 08:00
- 阅读 ( 163 )
- 分类:网络文章
你可能感兴趣的文章
随机文章
- hamburger drop down navigation bar is not visible when scrolling on a mobile site 195 浏览
- Why does this blocking queue code not work when I comment out a System.out.println? [duplicate] 205 浏览
- Pass Uint8List from dart to java over a TCPSocket 597 浏览
- Is there a way I can match this ArrayList so that burger1 get in place 1? 194 浏览
- Do the semantics of a project in bytecode change when changing all of its access modifiers to public? 236 浏览
相关问题
条评论
请先 登录 后评论
发送私信
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!