第一种:
public Point getDisplayMetrics() { DisplayMetrics dm = new DisplayMetrics(); dm = getApplicationContext().getResources().getDisplayMetrics(); int screenWidth = dm.widthPixels; int screenHeight = dm.heightPixels; return new Point(screenWidth ,screenHeight ); }
第二种:
public Point getDisplayScreen() { WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight(); return new Point(screenWidth ,screenHeight ); }