方法1:
public Point getDisplayMetrics() {
DisplayMetrics dm = new DisplayMetrics();
dm = getApplicationContext().getResources().getDisplayMetrics();
int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
return new Point(screenWidth ,screenHeight );
}
方法2:
public Point getDisplayScreen() {
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
return new Point(screenWidth ,screenHeight );
}
2种方法都可以获取当前display的screen尺寸。