2

我目前通过使用 ViewTreeObserver 来获取软键盘的高度,例如:

private final ViewTreeObserver.OnGlobalLayoutListener   mKeyboardLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        final int heightDiff = mRootLayout.getRootView().getHeight() - mRootLayout.getHeight();

        if(heightDiff > mStatusBarHeight && mLastHeightDiff != heightDiff){
            mSoftKeyboardHeight = heightDiff;
        }
        mLastHeightDiff = heightDiff;
    }
};

但是现在我需要在显示之前获取软键盘的高度,因为我们需要另一个视图具有与软键盘完全相同的高度。我怎么能那样做?

提前致谢

4

0 回答 0