Android获取屏幕宽高

//推荐
DisplayMetrics dm = getResources().getDisplayMetrics();
heigth = dm.heightPixels;
width = dm.widthPixels;

DisplayMetrics dm = new DisplayMetrics();
heigth = dm.heightPixels;
width = dm.widthPixels;

Display display = getWindowManager().getDefaultDisplay();
heigth = display.getWidth();
width = display.getHeight();

getWindowManager().getDefaultDisplay().getMetrics(dm);

你可能感兴趣的:(Android获取屏幕宽高)