1 public class ScreenUtils { 2 @SuppressWarnings("deprecation") 3 public static int[] getScreenDispaly(Context context){ 4 WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE); 5 int width=wm.getDefaultDisplay().getWidth();//手机屏幕的宽度 6 int height=wm.getDefaultDisplay().getHeight();//手机屏幕的高度 7 int result[] = {width,height}; 8 return result; 9 } 10 }