您的位置:首页 > 移动开发 > Android开发

Andoird 判断软键盘是否弹出

2013-09-27 15:43 253 查看
前言
         欢迎大家我分享和推荐好用的代码段~~
声明
         欢迎转载,但请保留文章原始出处:

         CSDN:
http://www.csdn.net

         雨季o莫忧离:http://blog.csdn.net/luckkof

正文

 

private boolean mHasInit = false;
private boolean mHasKeyboard = false;
private int mHeight;
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
super.onLayout(changed, l, t, r, b);
if(!mHasInit) {
mHasInit = true;
mHeight = b;
System.out.println("mHeight= "+b);
} else {
mHeight = mHeight < b ? b : mHeight;
}

if(mHasInit && mHeight > b) {                  //mHeight代表键盘的真实高度 ,b代表在窗口中的高度 mHeight>b
mHasKeyboard = true;
Xlog.e(TAG, "bottomBar---------------->出来了");
}
if(mHasInit && mHasKeyboard && mHeight == b) {  // mHeight = b
mHasKeyboard = false;
cancelBottomBarAnimation();
this.setVisibility(View.VISIBLE);
mShowing = false;
Xlog.e(TAG, "bottomBar---------------->隐藏了");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android