// 得到屏幕的宽 displayMetrics = getResources().getDisplayMetrics(); screenWidth = displayMetrics.widthPixels; // 得到标题栏和状态栏的高度 Rect rect = new Rect(); Window window = getWindow(); mImageView.getWindowVisibleDisplayFrame(rect); int statusBarHeight = rect.top; int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); int titleBarHeight = contentViewTop - statusBarHeight; // 得到屏幕的高 screenHeight = displayMetrics.heightPixels- (statusBarHeight + titleBarHeight);