Android怎样获取以像素为单位的屏幕尺寸

admin 提交于 周二, 02/10/2015 - 11:37

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

如果不在Activity里:

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

标签