singleTouchView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
private int heightDifference;
<a href="http://home.51cto.com/index.php?s=/space/5017954" target="_blank">@override</a>
public void onGlobalLayout() {
// TODO Auto-generated method stub
Rect r = new Rect();
layout.getWindowVisibleDisplayFrame(r);
int screenHeight = layout.getRootView().getHeight();
//键盘高度
heightDifference = screenHeight - (r.bottom - r.top);
if (heightDifference != 0) {
tl.setLayoutParams(new AbsoluteLayout.LayoutParams(
mWidth, mBottomHeight, 0, mHeight
- heightDifference - mBottomHeight));
tl.setVisibility(View.VISIBLE);
} else {
tl.clearAnimation();
tl.setVisibility(View.INVISIBLE);
}
}
});