前言
欢迎大家我分享和推荐好用的代码段~~
声明
欢迎转载,但请保留文章原始出处:
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---------------->隐藏了");
}
}