Android 获取手机屏幕大小两种方法

第一种:
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 );    
}

你可能感兴趣的:(android)