private class MyStateListener implements ViewTreeObserver.OnGlobalLayoutListener {
private final View mDecorView;
private final CameraFragment mFragment;
private int mFrameHeight = 0;
private boolean mKeyboardShow;
private final Rect mVisibleDisplayFrame;
IMEStateListener(CameraFragment paramView, View view) {
this.mFragment = paramView;
this.mDecorView = view;
this.mVisibleDisplayFrame = new Rect();
}
@Override
public void onGlobalLayout() {
this.mDecorView.getWindowVisibleDisplayFrame(mVisibleDisplayFrame);
int i = this.mVisibleDisplayFrame.height();
if (this.mFrameHeight == 0) {
this.mFrameHeight = i;
}
if (i < this.mFrameHeight) {
this.mKeyboardShow = true;
} else if (this.mKeyboardShow) {
this.mKeyboardShow = false;
mHandler.sendEmptyMessage(KEYBOARD_HIDE);
}
}
}原文:http://blog.csdn.net/xiaoguohaha/article/details/44665829