Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); // statusBarHeight是上面所求的状态栏的高度 int statusBarHeight = frame.top; //正文内容开始的高度 int contentViewTop = getWindow() .findViewById(Window.ID_ANDROID_CONTENT).getTop(); // 获取标题栏高度 int titleBarHeight = contentViewTop - statusBarHeight; Log.i("test", "statusBarHeight=" + statusBarHeight + " contentViewTop=" + contentViewTop + " titleBarHeight=" + titleBarHeight);