Andoir 判断软键盘是否弹出
前言 欢迎大家我分享和推荐好用的代码段~~
正文
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 ,