List of utility methods to do Screen Size Get
int | getMinTouchWidth(Context context) get Min Touch Width retrieveDisplayMetrics(context); return (int) (MIN_TOUCH_SIZE * _display_metrics.density * STANDARD_DPI); |
int | getDisplayHeight(Context context) get Display Height Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
return display.getHeight() - getStatusBarHeight(display.getWidth());
|
String | getDisplayMetrics(Context context) get Display Metrics WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); windowManager.getDefaultDisplay().getMetrics(metrics); return String.format("%dx%d", metrics.widthPixels, metrics.heightPixels); |
int | getDisplayWidth(Context context) get Display Width Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
return display.getWidth();
|
int | getRawDisplayHeight(Context context) get Raw Display Height Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
return display.getHeight();
|
int | getScreenHeight(Context context) get Screen Height WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.heightPixels; |
int | getScreenWidth(Context context) get Screen Width WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.widthPixels; |
int | getStatusHeight(Context context) get Status Height int statusHeight = -1; try { Class<?> clazz = Class.forName("com.android.internal.R$dimen"); Object object = clazz.newInstance(); int height = Integer.parseInt(clazz .getField("status_bar_height").get(object).toString()); statusHeight = context.getResources().getDimensionPixelSize( height); ... |
int | getScreenSize(@Nonnull Context context) Retrieves the screen size category for the device's default display from the Configuration values. Configuration conf = context.getResources().getConfiguration();
return conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
|
int | getScreenHeight(Context context) get Screen Height WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; |