Created
November 5, 2014 01:48
-
-
Save jimbray/c751bbe7665ff43d567d to your computer and use it in GitHub Desktop.
获取屏幕大小
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取屏幕大小 | |
* @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