Android利用Context获取屏幕尺寸

方法1:
  1. public Point getDisplayMetrics() { 
  2.    DisplayMetrics dm = new DisplayMetrics(); 
  3.    dm = getApplicationContext().getResources().getDisplayMetrics(); 
  4.    int screenWidth = dm.widthPixels; 
  5.    int screenHeight = dm.heightPixels; 
  6.    return new Point(screenWidth ,screenHeight );


  7. 方法2:
  8. public Point getDisplayScreen() { 
  9.    WindowManager windowManager = getWindowManager();
  10.    Display display = windowManager.getDefaultDisplay();
  11.    screenWidth  = display.getWidth();
  12.    screenHeight = display.getHeight();
  13.    return new Point(screenWidth ,screenHeight );
  14. }
复制代码

你可能感兴趣的:(Android利用Context获取屏幕尺寸)