一旦状态栏打开,是否可以知道活动的可见高度?
我想知道屏幕的可见高度。

最佳答案

尝试查看treeobserver方法..
像:

   main_layout.getViewTreeObserver().addOnGlobalLayoutListener(
            new OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout()
                    {

                        Rect r = new Rect();
                        // r will be populated with the coordinates of your view
                        // that area still visible.
                        main_layout.getWindowVisibleDisplayFrame(r);

                        int heightDiff = main_layout.getRootView().getHeight()-(r.bottom -r.top);

                    }
    });

用所需视图的对象替换主布局。
希望能有所帮助。

07-28 04:17