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);
                                                }
                                        }
                                });

posted on 2016-08-18 17:46  毕哥  阅读(406)  评论(0编辑  收藏  举报