我目前使用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;
}
};
但是现在我需要在显示它之前获得软键盘的高度,因为我们需要另一个视图来获得与软键盘完全相同的高度。我怎么能这样做?
提前致谢