Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);///取得整个视图部分,注意,如果你要设置标题样式,这个必须出现在标题样式之后,否则会出错 int top = rect.top;////状态栏的高度,所以rect.height,rect.width分别是系统的高度的宽度 View v = getWindow().findViewById(Window.ID_ANDROID_CONTENT);///获得根视图 int top2 = v.getTop();///状态栏标题栏的总高度,所以标题栏的高度为top2-top int width = v.getWidth();///视图的宽度,这个宽度好像总是最大的那个 int height = v.getHeight();////视图的高度,不包括状态栏和标题栏