//contentlayout是最外层布局View mChildOfContent;int usableHeightPrevious;
mChildOfContent = contentlayout.getChildAt(0);mChildOfContent.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() {
Rect r = new Rect(); mChildOfContent.getWindowVisibleDisplayFrame(r);
int usableHeightNow = r.bottom - r.top;
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard / 4)) {
} else {
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
} }});