Skip to content

Instantly share code, notes, and snippets.

@jimbray
Created November 5, 2014 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbray/c751bbe7665ff43d567d to your computer and use it in GitHub Desktop.
Save jimbray/c751bbe7665ff43d567d to your computer and use it in GitHub Desktop.
获取屏幕大小
/**
* 获取屏幕大小
* @param context
* @return
*/
public static int[] getScreenSize(Context context) {
DisplayMetrics dm = new DisplayMetrics();
//获取屏幕信息
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenWidth = dm.widthPixels;
int screenHeigh = dm.heightPixels;
int[] screen = {screenWidth, screenHeigh};
return screen;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment