List of utility methods to do Screen Size Get
int | getDisplayHeight(Context context) get Display Height if (displayHeight <= 0) { WindowManager wm = (WindowManager) context .getApplicationContext().getSystemService( Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); displayHeight = dm.heightPixels; return displayHeight; |
Point | getDisplaySize(Display display) get Display Size Point size = new Point(); display.getSize(size); return size; |
int | getDisplayWidth(Context context) get Display Width if (displayWidth <= 0) { WindowManager wm = (WindowManager) context .getApplicationContext().getSystemService( Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); displayWidth = dm.widthPixels; return displayWidth; |
int | getScreenHeight(Context context) get Screen Height WindowManager manager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; |
int | getScreenHeight(Context context) get Screen Height DisplayMetrics metric = new DisplayMetrics(); WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metric); return metric.heightPixels; |
int | getScreenHeight(Display display) get Screen Height Point size = getDisplaySize(display);
return size.y;
|
int[] | getScreenPixel(Activity activity) get Screen Pixel DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay() .getMetrics(displayMetrics); return new int[] { displayMetrics.widthPixels, displayMetrics.heightPixels }; |
int | getScreenWidth(Context context) get Screen Width WindowManager manager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; |
int | getScreenWidth(Context context) get Screen Width DisplayMetrics metric = new DisplayMetrics(); WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metric); return metric.widthPixels; |
int | getScreenWidth(Display display) get Screen Width Point size = getDisplaySize(display);
return size.x;
|