android获取屏幕宽高和状态栏高度

WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
int screenWidth = wm.getDefaultDisplay().getWidth(); //屏幕宽度
int screenHeight = wm.getDefaultDisplay().getHeight(); //屏幕高度

int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
// 状态栏高度
int statusBarHeight = getResources().getDimensionPixelSize(resourceId);

你可能感兴趣的:(android获取屏幕宽高和状态栏高度)